in reply to Returning multiple Hash references from a sub()

I tend to return a hashref, where each element in the hash contains a reference to something else.   (I choose to do so because that way each element is named, and that seems to work better as the code inevitably continues to expand.)   But the alternative of returning a list is a good one, too.   The each() function, for example, does this.

TMTOWTDI.   But, no matter what WTDI you eventually choose, make it abundantly clear, well documented, and maintainable.

Replies are listed 'Best First'.
Re^2: Returning multiple Hash references from a sub()
by moritz (Cardinal) on Sep 03, 2010 at 14:20 UTC
    If you need to return more than three hash refs, you can also start asking yourself if it wouldn't be clearer to return an object of some kind. (Often the answer is still "no", but not always).