Basic HTML version of Foils prepared Sept 20 97

Foil 54 Functions and Subroutines III --
local and my

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


The local construct defines dynamically-scoped variables as in Common Lisp
A call to local does not create a new variable! In effect, it makes a copy of its argument, whose original value is restored when the block is finished executing
local extends its scope to any function called from the block in which the local statement is defined
Perl5 introduced my, which creates true local variables whose scope is confined to the block in which they are defined
Note: one can use my or local in any block (not just a function) enclosed in { ... } to define temporary variables of limited scope



© 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 Sep 21 1997