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


1 The local construct defines dynamically-scoped variables as in Common Lisp
2 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
3 local extends its scope to any function called from the block in which the local statement is defined
4 Perl5 introduced my, which creates true local variables whose scope is confined to the block in which they are defined
5 Note: one can use my or local in any block (not just a function) enclosed in { ... } to define temporary variables of limited scope

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