![]() |
|
XP is just a number | |
PerlMonks |
Re^6: How to process multiple input files?by John M. Dlugosz (Monsignor) |
on May 23, 2011 at 19:22 UTC ( #906347=note: print w/replies, xml ) | Need Help?? |
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...".
In Section
Seekers of Perl Wisdom
|
|