Basic HTML version of Foils prepared April 16,1996

Foil 26 Some Remarks about Subroutines - III

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 Material -- April 16,1996. by Geoffrey C. Fox


1 Note differences between my() and local();
2 my($x); # declares $x to be private to this subroutine
3 local($x); # delares $x to be known to this subroutine and all those routines that it invokes
4 Typeglob or symbolic reference can be used to pass aruments by reference and not by value
5 This has usual advantage that subroutine alters "global" and not a "local" copy -- especially relevant for complex datastructures where you do not want expense of copying
  • Scalars are always passed by reference and not by value and by explicitly changing $_[0..], you can affect global scalars

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 Sat Sep 6 1997