in reply to Re^4: unxpected sort warnings while using sort
in thread unxpected sort warnings while using sort
In your case, your entire file is just one record (a string of space-separated numbers).
So, for this program, there is no difference whether or not you slurp the file.
Now - if you DID have multiple records, as in the first example I showed, without slurp, you get one record at a time. With slurp, it reads the entire file into memory, as a string, and it is up to you to separate the pieces.
In the majority of the cases, you normally process data files one record at a time, so the default of "NO SLURP" makes sense.
Sometimes, you need the entire content in memory before you can make sense of the file - for example, when reading config information, or an XML file. Typically, these would be small files, where memory consumption would not be an issue. A third case would be if you were comparing the contents of a smaller file with a larger one - you would read the smaller one into memory if possible.
"After Perl everything else is just assembly language."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: unxpected sort warnings while using sort
by perlynewby (Scribe) on Jul 24, 2015 at 23:03 UTC |