in reply to when is "my" not necessary?
you are setting to a GLOBAL variable, not lexical (defined by my). So if $_ is equal 'zero' you are setting:$$_ = foo ;
To really set a lexical variable you should use eval:$main::zero = foo ;
Note that when you writeeval("\$$_ = foo") ;
the $zero variable inside the string to be printed will point to a lexical variable, and all the symbolic references are evaluated at runtime and will point to the package (symbol table), in other words, will point to a global variable.my $zero ; ... print "$zero" ;
|
|---|