USAGE

objectify

The objectify function copies the hash reference (shallow copy), and blesses it into the given classname. If no classname is given, a meaningless, generated package name is used instead. In either case, the object will inherit from the Hash::Objectified class, which generates accessors on demand for any key in the hash.

As an optimization, a generated classname will be the same for any given objectify call if the keys of the input are the same. (This avoids excessive accessor generation.)

The first time a method is called on the object, an accessor will be dynamically generated if the key exists. If the key does not exist, an exception is thrown. Note: deleting a key after calling it as an accessor will not cause subsequent calls to throw an exception; the accessor will merely return undef.

Objectifying with a "real" classname that does anything other than inherit from Hash::Objectified may lead to surprising behaviors from method name conflict. You probably don't want to do that.

Objectifying anything other than an unblessed hash reference is an error. This is true even for objects based on blessed hash references, since the correct semantics are not universally obvious. If you really want Hash::Objectify for access to the keys of a blessed hash, you should make an explicit, shallow copy: