Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Answer: Is it better to return a hash of hashes or a reference to a hash of hashes?

by Russ (Deacon)
on Mar 05, 2002 at 20:04 UTC ( #149488=categorized answer: print w/replies, xml ) Need Help??

Q&A > subroutines > Is it better to return a hash of hashes or a reference to a hash of hashes? - Answer contributed by Russ

In the final analysis, it is up to you. One of the strengths of Perl is how it allows the programmer to work efficiently. The computer usually works efficiently, too, but the programmer's efficiency comes first.

So, if you decide it is better/easier/simpler to return an "expensive" data structure (rather than forcing your caller to dereference it later), then go right ahead! Unless you are doing something really "out there" (and I could give you some examples I have tried and discarded ;-) Perl will take good care of you.

  • Comment on Answer: Is it better to return a hash of hashes or a reference to a hash of hashes?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2016-12-06 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (119 votes). Check out past polls.