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


In reply to Re^5: unxpected sort warnings while using sort by NetWallah
in thread unxpected sort warnings while using sort by perlynewby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.