XP is just a number | |
PerlMonks |
Can you read a false value from a file?by grantm (Parson) |
on Feb 11, 2006 at 08:57 UTC ( [id://529538]=perlquestion: print w/replies, xml ) | Need Help?? |
grantm has asked for the wisdom of the Perl Monks concerning the following question: According to the perlsyn (Perl Syntax) man page ...
... is equivalent to ...
Conventional Perl wisdom has it that if you're not using $_, but assigning to a named variable ...
... then you should write it like this ...
The reason being, you only want the loop to terminate at the end of file (<FH> will return undef) and not when you read a line that happens to evaluate to false. My question is: Assuming $/ still contains the default value, is it possible to read a line which evaluates to false? A quick experiment shows that the string "0" is false, but "0\n" is true. Can anyone give a string with a trailing newline that evaluates to false in a boolean context? And, if changing $/ does make it possible, what would I have to change it to?
Back to
Seekers of Perl Wisdom
|
|