Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found