Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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]
[davido]: Lol, in composing test code for Re: Stupid, yet simple, sort question I managed to fill up /tmp for a moment, causing bash to complain about "pmbash: cannot create temp file for here-document: No space left on device"
[davido]: hm, sorry, wrong link: Re^3: Perl Program to efficiently process 500000 small files in a Directory (AIX) should be it.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-03-18 06:55 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (228 votes). Check out past polls.