my @row; while (@row = $sth1->fetchrow_array) { print "@row \n"; } #### my @resultarray; #### push @resultarray,\@row; #### return @resultarray; # returns list when called in list context return \@resultarray; # returns reference return wantarray ? @resultarray : \@resultarray; # adapt to calling context