Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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

Replies are listed 'Best First'.
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 contemplating the Monastery: (4)
As of 2016-06-27 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (335 votes). Check out past polls.