Basic HTML version of Foils prepared Sept 20 97

Foil 26 Some Remarks about Subroutines - III

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


Note differences between my() and local()
my($x); # declares $x to be private to the block
local($x); # declares $x to be known to this block and all routines invoked within the block
Typeglob or symbolic reference can be used to pass arguments by reference and not by value
This has usual advantage that subroutine alters "global" and not a "local" copy -- especially relevant for complex data structures where you do not want expense of copying
  • Scalars are always passed by reference (not by value); by explicitly changing $_[0..], you can affect global scalars



© 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