sub AUTOLOAD { # Filter out package information. (my $name = $AUTOLOAD) =~ s/.*:://; if (exists $subs{$name}) { *$AUTOLOAD = sub {$subs{$name}}; # This wont work! why? eval "sub $AUTOLOAD {$subs{$name}}"; # this will... fatalError("A compile error occurred while compiling the subro +utine $AUTOLOAD: $@") if $@; } else { fatalError("The undefined subroutine $AUTOLOAD was called."); } delete $subs{$name}; goto &$AUTOLOAD; }
Edit kudra, 2002-05-27 s/pre/code/, new title
In reply to autoload - why is eval needed in this example? by L0rdPhi1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |