in reply to Best way to return array or hash?

perldoc perlsub has a lot to say on this matter. Basically, all of the arguments to a function are passed-in as a list of scalars (any of which may be references), and what is returned is likewise ... a completely-flattened list of scalars.

From perldoc perlsub:   “If you return one or more aggregates (arrays and hashes), these will be flattened together into one large indistinguishable list.”

Later in that same document, under the heading “Pass by Reference”:   If you want to pass more than one array or hash into a function--or return them from it--and have them maintain their integrity, then you're going to have to use an explicit pass-by-reference. Before you do that, you need to understand references as detailed in perldoc perlref. This section may not make much sense to you otherwise... ”

Note:   this documentation-page can be found at http://perldoc.perl.org/perlsub.html#Pass-by-Reference, and of course, all the other perldoc pages are to be found there also.