Perl Best Practices is a little thin in this area. In (very brief) synopsis Damian suggests that you should "return what the caller expects".
In this case that may be return a list in list context and return an array reference in scalar context. You can achieve that by using wantarray:
sub genMeggaArray { my @array; ... return wantarray ? @array : \@array; }
In reply to Re: Return a Reference or Array?
by GrandFather
in thread Return a Reference or Array?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |