Samurai, local() operates on things that live in the symbol table - lexicals don't and you can't local()ize a lexical. You *can* use nested my() calls but that's almost always the wrong thing.
# This prints: # Lexicals: 12 # Globals: 34 use strict; # nested my() example my $lex = 1; { # local $lex; this line is a syntax error my $lex = 2; print "Lexicals: $lex "; } print "$lex\n"; # local()ized global our $global = 3; { local $global; $global = 4; print "Globals: $global "; } print "$global\n";
In reply to Re: Re: nuances of my, and maybe local
by diotalevi
in thread nuances of my, and maybe local
by Helter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |