I seem to recall trying an incantation very similiar to that, but it ended up causing deep recursion. It seemed that the *{name}{CODE} syntax was required to make it work right.
I suspect that what happens, is that a reference to the actual function in the module is lost when the glob gets reassigned. The reference held in $old is to a glob, and calling a function on it essentially references *{$old}{CODE}, which isn't really what you wanted (because it's the new one). That causes recursion.
If I'm understanding that wrong, someone please correct me.
-Dave
Comment on Re: Re: Ambiguous use of X resolved to Y
That could happen if the function didn't already exist before you took a reference from it. Be sure to have loaded the code for that function before you run that snippet. Consider also checking for recursion:
my $old = \&Pod::HTML::scan_podpath;
{
local $^W;
*Pod::HTML::scan_podpath = sub {
if ( $old == \&Pod::HTML::scan_podpath ) {
croak "...";
}
&{$old}( @_ );
};
}