The construct local defines variables which are local(private) to a particular function |
For example the routine on following foil invoked by |
@new = &bigger_than(100,@list); |
Returns in @new all entries in @list which are bigger than 100. |
local() is an executable statement -- not a declaration! |
The first two statements in bigger_than can be replaced by: |
local($test,@values) = @_; # local() returns an assignable list |
In Perl5, my tends to eplace local as my scope confined to routine but local extends scope to any function called from block in which local statement defined |
Note can use my/local in any block (not just a function) enclosed in { ... } to define temporary variables of limited scope |