Basic HTML version of Foils prepared Sept 20 97

Foil 30 Some Remarks about Subroutines - VII -- AUTOLOAD

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


1 One can define a default function AUTOLOAD to resolve unsatisfied subroutine references in a given (set of) packages
2 You set up AUTOLOAD to deal with this case in whatever way you want!
3 AUTOLOAD is passed arguments that were passed to called subroutine and name of unsatisfied external is in variable $AUTOLOAD
4 sub AUTOLOAD { # Call UNIX for unsatisfied externals
5 my $program = $AUTOLOAD;
6 $program =~ s/.*:://; # remove any package precursors
7 system($program, @_);
8 }
9 date(); # will be executed correctly by above AUTOLOAD

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Apr 5 1998