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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Undocumented variable?
by Zaxo (Archbishop) on Sep 12, 2003 at 21:36 UTC | |
by merlyn (Sage) on Sep 13, 2003 at 13:33 UTC | |
by Dog and Pony (Priest) on Sep 13, 2003 at 14:25 UTC | |
by Mr. Muskrat (Canon) on Sep 13, 2003 at 14:30 UTC | |
by Rudif (Hermit) on Sep 13, 2003 at 16:41 UTC | |
by merlyn (Sage) on Sep 13, 2003 at 17:03 UTC | |
by wirrwarr (Monk) on Sep 13, 2003 at 18:13 UTC | |
by Rudif (Hermit) on Sep 14, 2003 at 06:23 UTC | |
by dmitri (Priest) on Sep 12, 2003 at 22:15 UTC | |
by kirbyk (Friar) on Sep 12, 2003 at 23:26 UTC | |
Re: Undocumented variable?
by Mr. Muskrat (Canon) on Sep 12, 2003 at 21:39 UTC | |
by Abigail-II (Bishop) on Sep 12, 2003 at 22:04 UTC | |
Re: Undocumented variable?
by jonadab (Parson) on Sep 13, 2003 at 04:08 UTC | |
Re: Undocumented variable?
by dpmott (Scribe) on Sep 12, 2003 at 21:29 UTC |
Back to
Seekers of Perl Wisdom