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

Re: Difference between a declared hash and stored one with storable.

by McA (Priest)
on Feb 06, 2014 at 08:13 UTC ( [id://1073661]=note: print w/replies, xml ) Need Help??


in reply to Difference between a declared hash and stored one with storable.

Hi,

just my opinion:

When you use require and you use this hash everywhere than you could also make a module (*.pm) with a module global hash and simply use this module. This would transfer the instantiation time of the big hash to the compile time. A hash in perl notation is simpler to edit than a hash represented as a Storable object.

I would think much more about another thing. When you use the global hash the using party has to know the keys and the structure of that hash. Therefore the knowledge about the hash is spread all over the code which uses it. That makes it hard to change somthing in teh hash when you have to. I would encapsulate the whole hash into a object holding the informations and querying this object with methods which fit the common use cases. This gives you an abstraction from the way you implemented it. Then you can store it as a package global hash, as a hash which you slurp at runtime via require or you slurp a storable representation of that hash or you put the whole thing into a database. You can even change the structure as long as the querying methods don't change their API.

Best regards
McA

  • Comment on Re: Difference between a declared hash and stored one with storable.
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1073661]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-19 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found