I basically want to put a wrapper around a function when it's declared with a particular attribute. This would normally be easy, because when the handler is run, you get a reference to the symbol, so you can do this:
sub myhandler : ATTR(CODE) {
my($pkg, $symbol, $referent....) = @_;
...
*{$symbol} = sub {
# additional code
goto &$referent;
}
}
However, the script(s) that uses the attribute is called from do(). That means that the CHECK and INIT blocks are not run. I tried changing the handler to be invoked at BEGIN time, but the problem there is that the $symbol is a string that says "ANON". So I have no where I can assign the newly generate sub.
Does anybody know a way to workaround this?