in reply to Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };
It may be useful to restrict the scope of the file handle as well, since slurping is a one pass approach. That may be done with
or, better if lexical filehandles are available,my $string = do { local $/; open local(*FILEHANDLE), 'somefile.txt' or die $!; <FILEHANDLE> };
since the lexical handle is properly closed when it goes out of scope. Either way ensures no interference with other handles of the same name.my $string = do { local $/; open my $fh, 'somefile.txt' or die $!; <$fh> };
After Compline,
Zaxo
In Section
Meditations