in reply to Cheap idioms

A more robust method is:

my $data= do { local( *ARGV, $/ ); @ARGV= $filename; <> };
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.

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)