Take a closer look at the the eof docs. Using the form eof() uses the same magic as while (<>) to pull input from STDIN if no filenames are passed on the command line. Using eof() is best reserved for use only inside the while (<>) construct for that same reason. Why the behavior is different in 5.6, I'm not sure, but this is documented at least back to 5.004_04.

The simplest solution is to remove the parentheses from the eof call, which will cause the builtin to default to the last filehandle read. The other solution is to name the filehandle explicitly. The latter is a better habit, anyhow; if file-handling code were to sneak in between your last read and the call to eof, the no-parens form would use the other handle instead of SAVEF as you intended.

As an aside, are you sure you need to be using eof at all? Perl's input operators return undef when they run out of input; eof is more of a C holdover than a critical function. Your while loop looks rather strange (perhaps because you didn't use <code> tags--I think you meant while (<SAVEF>)), so it's hard to tell what you were intending. If you're trying to get at the last line of the file, see this FAQ.

Update: Expanded upon reply.


In reply to Re: Behavior change in 5.6?? by athomason
in thread Behavior change in 5.6?? by mdchachi

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.