Joining every line is less efficient, as you wind up searching for newlines to break into lines, allocating an array, filling it, joining it and assigning to a scalar.
The standard approach turns off the newline searching and just reads it to a scalar in a single shot.
See the discussion in the documentation for File::Slurp.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: slurp mode
by xdg
in thread slurp mode
by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |