Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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

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

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


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

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073661]
[LanX]: yep
[erix]: or Ctrl-U to view current html :P
[LanX]: name not id
[LanX]: id isn't approved AFAIK
[LanX]: name works
erix feels silly for having actually tested that contiguous values make no difference in CLUSTERing a table (At least, in postges)
[LanX]: Perl Monks Approved HTML tags
[LanX]: erix and his postguess ...
[erix]: (Grrres...)
[dabella12]: I have a problem install tK on CeontOs using perl 5.24

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-06-24 13:30 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (557 votes). Check out past polls.