With read, you are telling it how big the file is, so it can preallocate a buffer to that size and fill it in a single call to the system (even if the system chooses to break it into smaller reads from disk). So, one call to the system to allocate the memory. One call to perform the read.
With the traditional slurp, it doesn't know how big the file is, so it
Try using:
my $data = do{ local $/ = \( -s FILE ); <FILE> };;
In reply to Re: Speed reading (files)
by BrowserUk
in thread Speed reading (files)
by kwaping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |