dpmott has asked for the wisdom of the Perl Monks concerning the following question:
So, I was quickly coding up a proof-of-concept script today, and I fat-fingered a line that was supposed to check the $@ variable. However, the compiler didn't catch my use of the undocumented global array @$.
So I wrote some test code:
I don't mind if I get dyslexic with '$$', but '@$' should be some kind of compile-time error, IMHO.
Unless it's actually used for something? Anyone?
Thanks,
-dpmott
#!perl use strict; # need to pre-declare variables... @$ = (1, 2, 3, 4); # I wonder what this is? eval { die "blah"; }; # This sets $@ print join(', ', @$); # prints '1, 2, 3, 4'Could someone please tell me what the @$ array is, what it's used for, and/or why the compiler doesn't warn or die when I use it? It's not documented in perlvar or any reference material that I have. One of my co-workers speculated that the implementation probably reserved the glob of '$' variables, since there's the '$$' variable...
I don't mind if I get dyslexic with '$$', but '@$' should be some kind of compile-time error, IMHO.
Unless it's actually used for something? Anyone?
Thanks,
-dpmott
Back to
Seekers of Perl Wisdom