in reply to Weird DBI/Array Use
Rather than rolling your own version of this, perhaps you could use $dbh->selectall_arrayref instead?
Then you can do something like:
sub db_execute { ... return $dbh->selectall_arrayref($query); } my $result = db_execute($SQL); foreach my $row (@$result) { my ($a, $b, $c) = @row; ... }
Note that this way you can also skip the 'prepare' stage you're doing, as it seems pretty pointless the way you're doing it (you're not gaining any of the benefit of preparing frequently-used queries by doing it inside this sub). However, if you move the 'prepare' elsewhere, and pass this subroutine a prepared query instead, selectall_arrayref will still handle this just fine.
Tony
|
|---|