sub test {
if (wantarray){
return 'One String';
} else {
return ('A', 'List', 'of', 'Strings');
}
}
####
sub fetchall_arrayref {
my $slice= shift || [];
my $mode = ref $slice;
if ($mode eq 'ARRAY') {
push @rows, [ @$row ] while($row = $sth->fetch);
}
elsif ($mode eq 'HASH') {
push @rows, $row while ($row = $sth->fetchrow_hashref);
}
else {
Carp::croak("fetchall_arrayref($mode) invalid")
}
return \@rows;
}
####
$sth->fetchall_arrayref( [] ) # returns Array references
$sth->fetchall_arrayref( {} ) # returns Hash references