A widespread and broken Perl idiom
The following code is using a widespread Perl idiom, taking advantage of features designed for one-liners:
my $content = do { local ( @ARGV, $/ ) = ("$file"); <> };
Another trick here is the array assignment, which slurps all elements of the list into @ARGV
, leaving $/
to undef
; that way, the diamond operator will read the entire file at once.
I've been using and publicizing this local @ARGV
idiom for years. And I've spent several days last week chasing a bug caused by this line of code.