note
tye
<p>
A more robust method is:
<code> my $data= do { local( *ARGV, $/ );
@ARGV= $filename; <> };
</code>
because your method doesn't localize changes to <code>$ARGV</code> and <code><ARGV></code> and so, if used in a subroutine that is used by a program that is using <code><></code>, your method can break the outer program.
</p><p>
Note that prior to Perl v5.6.0 (I think) this idiom didn't work correctly.
</p><p>
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.
</p>
- [tye] (see one [id://78754|prior discussion])
204874
204874