in reply to Return a Reference or Array?

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; }

True laziness is hard work