我需要拉出与 column 对应的行name
。被拉出的行对应于数组中的地址@values
。以下是我的代码:
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
但是当我打印时@names
,我没有得到任何输出,我不确定出了什么问题。