For example, suppose you want to wrap Apache::Session, so that on first store or fetch, it does some init before becoming a real session object...
package My::Apache::Session; sub TIEHASH { my $class = shift; bless [@_], $class; # remember real args } sub FETCH { ## DO NOT USE shift HERE $_[0]->my_initialization; $_[0] = Apache::Session->TIEHASH(@{$_[0]}); goto &{$_[0]->can("FETCH")}; } sub STORE { ## DO NOT USE shift HERE $_[0]->my_initialization; $_[0] = Apache::Session->TIEHASH(@{$_[0]}); goto &{$_[0]->can("STORE")}; } sub my_initialization { ... }
In reply to Changing the hidden tied object by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |