in reply to Cheap idioms
A more robust method is:
because your method doesn't localize changes to $ARGV and <ARGV> and so, if used in a subroutine that is used by a program that is using <>, your method can break the outer program.my $data= do { local( *ARGV, $/ ); @ARGV= $filename; <> };
Note that prior to Perl v5.6.0 (I think) this idiom didn't work correctly.
And these are exactly the reasons why I much prefer to use a good module over some idiom. That way improvements can be centralized in one place.
- tye (see one prior discussion)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (tye)Re: Cheap idioms
by Juerd (Abbot) on Oct 13, 2002 at 20:51 UTC | |
by Anonymous Monk on Oct 13, 2002 at 21:59 UTC | |
by Juerd (Abbot) on Oct 14, 2002 at 05:54 UTC | |
by Sihal (Pilgrim) on Oct 17, 2002 at 11:31 UTC | |
by Aristotle (Chancellor) on Oct 17, 2002 at 13:24 UTC | |
by Sihal (Pilgrim) on Oct 17, 2002 at 13:48 UTC | |
by Aristotle (Chancellor) on Oct 17, 2002 at 14:06 UTC | |
| |
by ysth (Canon) on May 29, 2008 at 20:09 UTC |
In Section
Meditations