Next Tricks of the Wizards 103

Function Call Caching

        sub closethewindow { ... }
        sub AUTOLOAD {
          my ($package, $func) = ($AUTOLOAD =~ /(.*)::(.*)/);
          my $true_func = join '::', $package, lc $func;
          if (defined &$true_func) {

            *$AUTOLOAD = \&$true_func;
            goto &$AUTOLOAD;
          }
          croak "Undefined subroutine &$AUTOLOAD";
        }


Next Copyright © 2003 M. J. Dominus