in reply to Re^4: unxpected sort warnings while using sort
in thread unxpected sort warnings while using sort

The "slurp" setting reads all "records" of the file in one shot.

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."

  • Comment on Re^5: unxpected sort warnings while using sort

Replies are listed 'Best First'.
Re^6: unxpected sort warnings while using sort
by perlynewby (Scribe) on Jul 24, 2015 at 23:03 UTC

    thank you all for your patience while explaining these basic things that you have gained, experienced and learned

    as a beginner, I read and try to use the stuff I've read into practice ergo my little programs I try to create to test the stuff i read...sometimes, I don't know (forsee) the problems until I get there...then read to solve and still not know the answer...so I ask coz there still too many variables for me as a new perl beginner that may be the source of issues...so I DO appreciate knowledge of practice and experience from you monks.

    thank you