perl - How to compare array from file with sql database query? -
this question has answer here:
i tried select columns table @ database same on row in array in file. example:
table: id name 1 2 b 3 c file: b
i want select , b.
my source:
use dbi; use cgi; $file = '.\input.txt'; # name file open(file, $file) or die("unable open file"); @data = <file>; foreach $line (@data) { #print $line; $sth = $dbh->prepare("select columna table columna '%$line%'"); $sth->execute; $result = $sth->fetchall_arrayref; foreach $row ( @$result ) { print "- "; print "@$row\n"; print "<br />"; } }
but write last line of select hmmm...
output b output want b
i tried this:
input: bengalske_stehno cesnakova_polievka drzkova_polievka kuraci_spiz polievka_fazulova polievka_mrkvova polievka_rybacia database: fasirky cesnakova_polievka chlebicek_biskupsky drzkova_polievka polievka_fazulova polievka_mrkvova polievka_rybacia bengalske_stehno output: - polievka_rybacia
it seems forgot chomp $line
after reading input file. newline not present on last line in file, that's why works.
Comments
Post a Comment