I have Perl code like so:
$pre = $dbh->prepare("select distinct skills from people");
$pre->execute;
my @preList;
while (my $row = $pre->fetchrow_array()) {
push (@preList,$row);
}
print "Pre list: $_" foreach @preList;
When I try the exact same statement in sql it works perfectly, but when I run this program it prints out nothing (suggesting an empty @preList). I am probably doing something very stupid, but cannot see it. I have used this format for getting data before, which works perfectly. Can anyone see what I’ve done wrong?
Right now you are doing,
fetchrow_arraywhich returns a list but you are trying to store it in a scalar, you can either change it tofetchrow_arrayrefor change$rowto@row, or changemy $rowtomy ($row).