It encourages "one-pass" processing of files. In other words it is more efficient to only read a file once (start to end). Structuring your code so that you don't need to make multiple passes through a file will make your program consume less resources and will most likely make your program more efficient.

Thanks. That makes some sense, but, honestly, I'd rather have perl treat coders as adults who can decide for themselves how many times they want to read their files. In this case, the file is about 50kB long. Even supposing that it's not left in memory between two reads, it can be read from my SSD again in a matter of milliseconds. Not a lot of time compared to the hours I spent looking to find out what's wrong, I think you'll agree.
On a more general note, I'd expect the TTMWTDI ethos to extend to allowing such "dumb" multiple reads on a filehandle, maybe throwing a warning if strictures are on. As it is, perl just fails to execute the second while loop without throwing any warning whatsoever, and whichever way you look at it, that's not very coder-friendly.

In reply to Re^2: Trying to do multiple while loops on the same input file by elef
in thread Trying to do multiple while loops on the same input file by elef

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.