http://qs321.pair.com?node_id=906347


in reply to Re^5: How to process multiple input files?
in thread How to process multiple input files?

It's not a problem with normal line-oriented use because the \n character is present on the end of every line with the possible exception of the last which then won't be empty. You got "0\n" in the string, not an empty string, not "0" alone.

Try something like: while ( my $line = <> ) { say !!($line) } print $. and you'll see that each read is True as well as being defined.

Recall as I explained originally, I'm concerned with totally empty files causing an empty string and testing false, or (less likely because it doesn't look like an xml file) a file containing a 0 only and no terminating end-of-line.

However, I do stand corrected, after checking the perl IO reference: I was thinking that the special meaning of Truth applied only to implicit assignment to $_ in the condition. However, the 5.14 docs does indeed say "the assigned value (whether assignment is automatic or explicit) is then tested to see whether it is defined...".