Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Object and tied hash all at once?by btrott (Parson) |
on Jul 07, 2001 at 00:54 UTC ( [id://94606]=note: print w/replies, xml ) | Need Help?? |
Yes, this is possible. Tie::SecureHash is an example of
a class that does this. In order to get the object and tied hash interface all at once, though, you have to be slightly tricky, and you need to create your object using the object constructor interface, not the tie interface: That returns a reference to the tied hash, which is also an object that is blessed into $class, which means that you can either use it as a tied hash, *or* call methods on it. (NOTE: In the above example, the object is blessed into the tie class, but this is not required.)
In Section
Seekers of Perl Wisdom
|
|