in reply to Attribute Handlers don't run when called at run time.
In your case I might do something like this in the parent class (untested):
And then in your child class you write:sub wrap_sub { my ($class, $function) = @_; no strict 'refs'; no warnings 'redefine'; my $referent = \&{"$class\::$function"}; my $wrap_sub = sub { warn 'before'; $referent->( @_ ); warn 'after'; }; warn "wrap_sub wrapping: $class\::$function"; no warnings 'redefine'; *{"$class\::$function"} = $wrap_sub; return; }
sub foo { warn 'fooooo'; } __PACKAGE_->wrap_sub("foo");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Attribute Handlers don't run when called at run time.
by bennymack (Pilgrim) on Sep 04, 2008 at 15:56 UTC | |
by tilly (Archbishop) on Sep 04, 2008 at 17:15 UTC |