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

<> slurps both files at once.
# echo FOO > foo # echo BAR > bar # perl -wE'say <>; say "Done";' foo bar FOO BAR Done #

Replies are listed 'Best First'.
Re^2: eof not recognised when applying diamond operator to invocation arguments?
by pat_mc (Pilgrim) on Jan 12, 2011 at 16:46 UTC
    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.
      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.