I often have a subroutine in Perl that fills an array with some information. Since I\'m also used to hacking in C++, I find myself often do it like this in Perl, using refer
If I look at your example and think about what you want to do I'm used to write it in this manner:
sub getInfo {
my @array;
push @array, 'obama';
# ...
return \@array;
}
It seems to me as straightforward version when I need return large amount of data. There is not need to allocate array outside sub as you written in your first code snippet because my do it for you. Anyway you should not do premature optimization as Leon Timmermans suggest.