Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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?
[choroba]: bit vectors as keys?
[robby_dobby]: Hmm, I keep falling asleep at my desk, while maintaining an active appearance. Am I getting old?
[robby_dobby]: Every time I fall asleep, there's a small guy in the dreams, shouting "Whoo!" and it jolts me awake. :/
[Lady_Aleena]: robby_dobby, at least you aren't driving. I seem to always be driving somewhere in my dreams and end up at a weird house.
[robby_dobby]: LA: That's there. But this is work and it's the same thing as falling asleep driving :-)
[Lady_Aleena]: I love the dream where I was at a huge house and decided to go swimming in the pool, but then the tour group showed up.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-05-29 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?