http://www.perlmonks.org?node_id=1217663


in reply to Any downsides to this slurp idiom?

Thanks everyone for your replies! :-) For completeness, here are some slurping examples, incorporating various suggestions:

Minor edits for clarity.

Update 2: Actually, I made a mistake in the last example when I first fixed it, it is now tested and correct.

Replies are listed 'Best First'.
Re^2: Any downsides to this slurp idiom?
by choroba (Archbishop) on Jul 09, 2018 at 16:46 UTC
    Note that localizing @ARGV could be not enough (because eof(ARGV) might remain true). So,
    my $data = do { local ( *ARGV, $/ ); @ARGV = ("$file"); <> };

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,