"be consistent" | |
PerlMonks |
Re: Tieing ans Blessingby tobyink (Canon) |
on Oct 05, 2012 at 09:13 UTC ( [id://997414]=note: print w/replies, xml ) | Need Help?? |
Tied hashes are backed by objects. If you have a tied hash %foo then you can access the underlying object using tied(%foo). You can call methods on it like tied(%foo)->my_method(42). If you have a tied hash, yes, it's also possible to bless a reference to that hash into a particular class. This may even be a different class to the one used to implement the tied behaviour. And here's a quick example to show a hash tied to one class and blessed into another...
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|