in reply to Weird DBI/Array Use

How about:
sub db_execute { my(@return, @a, $cursor); unless ($VARS{connected}) {db_connect(); $VARS{connected}++;} $cursor = $dbh->prepare($_[0]) || db_error(); $cursor->execute || db_error(); unless ($_[1]) { return @{ $cursor->fetchall_arrayref }; } } my $SQL = "select a, b, c from my_table"; my @rows = db_execute($SQL); for (@rows) { my @row = @$_; ... }
(I'm not sure what the unless($_[1]) is for...)

Update: Use fetchall_arrayref() instead of looping over fetchrow().