![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: (tye)Re: Cheap idiomsby Juerd (Abbot) |
on Oct 13, 2002 at 20:51 UTC ( #204937=note: print w/replies, xml ) | Need Help?? |
A more robust method is... Redundancy :) I don't like typing ARGV twice, but realise localizing *ARGV is necessary. Thanks for the pointer - I think I'm very fortunate to not have been bitten by this yet. Since you can assign a reference to a typeglob to set only one data type associated with it, simply adding brackets solves my problem of having to type the four uppercase letters twice. *foo = [ 1, 2, 3 ]; is like @foo = (1, 2, 3);, but with rather different semantics.
Note that prior to Perl v5.6.0 (I think) this idiom didn't work correctly. A quick, possibly broken test (perl5.005 -e'print do { local (@ARGV, $/) = "/etc/passwd"; <> }') shows that the unaltered version works with perl 5.005. But that one is broken. Any version of this idiom localizing *ARGV doesn't work with perl5.005, so your version doesn't play nice with it. That is not at all a problem, though. I don't use perls older than 5.6.0 anymore, except when explicitly asked. It's time we moved on to newer versions. There's perl 5.8.0 already, and people are still using 5.005. The _03 release is over three years old now. I put use 5.006; in my code to make sure things break as soon as possible. I even use use v5.6; sometimes, just to nag :)
In Section
Meditations
|
|