I am required to pull out rows corresponding to column name
. The rows being pulled out correspond to address in array @values
. Following is my code:
use strict;
use DBI;
open (FH, "/user/address") or die $!;
my@values=<FH>;
close(FH);
my @names;
my $query = "Select name from table where address = ?";
my $sth = $dbh->prepare( $query ) or die "could not prepare statement\n", $dbh->errstr;
foreach my $value(@values){ #@values contain list of address
$sth->execute($value) or die "could not execute statement $query\n", $sth->errstr;
while ($result = $sth->fetchrow_hashref()){
my $name_reqd = $result->{name};
print "Name Req: $name_reqd\n"; #not printing anything
push (@names, $name_reqd);
}
}
print "@names\n"; #not printing anything
But when I print @names
, I don't get any output, I am unsure as to what is going wrong.