in reply to A correction to my earlier comment about format
use strict; $a = 'woof'; my $a = 'meow'; print "lexical \$a: $a\n"; print "package \$a: $main::a\n";
Had you used local rather than my, then $a would have been masked in the symbol table -- $main::a would reflect the local value through the rest of the declaration scope, even by reference:
use strict; $a = 'woof'; $a_ref = \$a; local $a = 'meow'; print "\$a: $a\n"; print "package \$a: $main::a\n"; print "ref to package \$\$a: $$a\n";
Matt
|
|---|