in reply to
Re: Re^3: Cheap idioms
in thread Cheap idioms
The diamond operator (<>) will go through all elements of @ARGV in sequence, open and read them, one after another. So you localize @ARGV, meaning you make a "private copy" of it for the duration of the block, put just one filename in it, the one you wish to read, and also make a local copy of $/ (which contains what Perl is to assume an end-of-line; see perldoc perlvar) without actually putting any value in it, meaning you'll slurp the entire content from any file handle at once. As the diamond operator is the last thing in the block, its result becomes the "return value" of the block.
And thus, the slurped file content ends up in the variable.
Makeshifts last the longest.