Query local MySQL database table from a list of wordforms

#!/usr/bin/perl -w
# sends words in a file to CroALa MySql table with names forms, reports what was found
# usage (in pipe): perl ambig-local.pl
use strict;
use warnings;
use DBI;
 
while (my $verbum = <>) {
 	chomp $verbum;
my $dbh = DBI->connect('dbi:mysql:DBNAME','DBUSER','DBPASSWORD')
or die "Connection Error: $DBI::errstr\n";
# mysql instruction forbidden in dokuwiki, see below:
my $sql = "FORBIDDENWORD lemma from croala_lemmadb where forma = '$verbum'";
 
 my $sth = $dbh->prepare($sql);
 $sth->execute
or die "SQL Error: $DBI::errstr\n";
 	if ($sth->rows != 0) {
            print $verbum, ": EST LEMMA\n";
          } else
          { open LOG, '>>:encoding(UTF-8)', $$ . '-no-local-lemma';
          print LOG $verbum, "\n";
	  }
 }

FORBIDDENWORD is SELECT

 
z/ambig-local.pl.txt · Last modified: 20. 01. 2013. 15:36 by njovanov
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki