The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You can only localize a "package global variable" but not a lexical variable i.e., declared using "my".
A package global can be created using "use vars qw($pkg_gbl_bar1 $pkg_gbl_bar2)".
Please change your code as below
use strict; use vars qw($tt); $tt = 3.14159; { local $tt = 3; print "In block, \$tt = $tt\n"; print "In block, \$::tt = $::tt\n"; } print "Outside block, \$tt = $tt\n"; print "Outside block, \$::tt = $::tt\n"; Hope this helps you. If I am wrong, please let me know. In reply to Re^4: The difference between my and local
by Nazeerahamed
|
|