http://www.perlmonks.org?node_id=1073661


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