Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: eof not recognised when applying diamond operator to invocation arguments?

by pat_mc (Pilgrim)
on Jan 12, 2011 at 16:46 UTC ( #881943=note: print w/ replies, xml ) Need Help??


in reply to Re: eof not recognised when applying diamond operator to invocation arguments?
in thread eof not recognised when applying diamond operator to invocation arguments?

Yep ... that's obviously correct. My question was 'WHY'. I would have assumed that the end-of-file information does not get lost when I used the diamond operator to read the input files line by line. Why is the code I posted not behaving equivalently to

while( <> ) { print; print "========================== Now at $ARGV =================== +=======\n" if eof; }
which prints the contents of the first file, then the separator, then the contents of the second file and the separator again.


Comment on Re^2: eof not recognised when applying diamond operator to invocation arguments?
Download Code
Re^3: eof not recognised when applying diamond operator to invocation arguments?
by Anonyrnous Monk (Hermit) on Jan 12, 2011 at 16:53 UTC
    Why is the code I posted not behaving equivalently to ...

    because in your original code the eof is tested only once before everything is being read and output.  In the second case, it's tested for every line, so it has a chance to detect the end-of-file conditions.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-12-28 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls