The one thing I notice about your code is that you have three loops that read from <>. It is possible that some difference in the input results in the inner functions reading extra data. t is also possible that you missed a spot when changing the code so it was reading from a different file handle. You might want to add debugging code to print the line number and file for each line to see that the right file and lines are being read.
print STDERR "$ARGV:$.:$line";

I would suggest rewriting the code so that there is only one loop that reads lines. Use flags or a state variable to control the processing. This makes it easier to analyze where the file is being read and what the state the processing is in at each stage.


In reply to Re: Using null filehandle by iburrell
in thread Using null filehandle by digger

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.