in reply to Re: Re: AUTOLOAD & mod_perl memory
in thread AUTOLOAD & mod_perl memory

$subclass->new_meth will set $AUTOLOAD to "SUBCLASS::new_meth" so will install the closure there. If later I call $other_subclass->new_meth then I'll get another sub in OTHERSUBCLASS::new_meth.

"Doctor, it hurts when I do this" :-)

Put it in the base class - this should do what you want:

sub AUTOLOAD { my ($fn) = ($AUTOLOAD =~ /^.*::(.+)$/); return if $fn eq 'DESTROY'; *{$fn} = sub { print "$AUTOLOAD $fn\n"; }; goto &$fn; }

Replies are listed 'Best First'.
Re: x4 AUTOLOAD & mod_perl memory
by bsb (Priest) on Dec 04, 2002 at 02:27 UTC
    Yep. Noted in the original post, 2nd para.

    perrin's reply made the path clear. Your AUTOLOAD does address pike's problem and is properly inheritable.

    *{$base."::".$fn} = sub { print "$AUTOLOAD $fn\n"; };