|
|
| Just another Perl shrine | |
| PerlMonks |
Re: Referencing the localsby davido (Cardinal) |
| on Apr 28, 2021 at 19:18 UTC ( [id://11131813]=note: print w/replies, xml ) | Need Help?? |
|
Don't wield symbolic references for this purpose. You don't need them here. Use strict to disabuse yourself of any temptation. Why it's stupid to use a variable as a variable name. In your code above, ${'a'} is a symbolic reference to a package global named $main::a. And ${a} is synonymous with $a, which in the scope you're using it in, refers to the lexical version of $a, not the package global. Instead, either use real references, or a hash:
...or do this...
Dave
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||