That obviates the need for a while loop. Normally, $/ is set to a newline. That's why the magic <FILEHANDLE> reads one line at a time. Using a local $/ will change that to whatever separator you want. Specify none, slurp the whole thing. That could make your first example even more compact.local $/; my $scalar = <FH>;
In reply to RE: Return the contents of a file
by chromatic
in thread Return the contents of a file
by jamescohen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |