1 | The construct local defines variables which are local(private) to a particular function |
2 | For example the routine on following foil invoked by |
3 | @new = &bigger_than(100,@list); |
4 | Returns in @new all entries in @list which are bigger than 100. |
5 | local() is an executable statement -- not a declaration! |
6 | The first two statements in bigger_than can be replaced by: |
7 | local($test,@values) = @_; # local() returns an assignable list |
8 | 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 |
9 | Note can use my/local in any block (not just a function) enclosed in { ... } to define temporary variables of limited scope |