in reply to Re-post: hashes frustration
in thread hashes frustration
You're not putting an object in the hash, so you can't call a method on it later. What you're actually doing is calling a class method on the package that corresponds to whatever pack() returns.
The first form works because you are re-blessing the packed version into the class that contains the unpack_name() method. I'm not sure why the second form works at all without resulting in an error, actually.
There are modules on the CPAN that will let you tie() a hash to a database and then store and fetch references (including blessed ones) from them, or you could roll your own with Storable or FreezeThaw or the like.
|
|---|