in reply to Re: String comparison "\x00" vs. "".
in thread String comparison "\x00" vs. "".
There are some exceptions to 1 above. If the character contained is numerically zero, then despite having length, the string will conditionally test as false.There are only exceptions to the exception because of you convoluted way of writing what is false. If you state it as:
...
And then there are (the celebrated) exceptions to the exception, like "0e0" (& "0e-0" & ... ) that the 'type safety' people hate, but that help make the world go around.
An expression is false if it (in scalar context -- boolean context is scalar context) evaluates to any of the following:
Update: if a variable has both string and numerical values, then the truth value of the string part wins:
use Scalar::Util 'dualvar'; my $p1 = dualvar 0, "foo"; # True my $p2 = dualvar 1, ""; # False
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: String comparison "\x00" vs. "".
by ikegami (Patriarch) on Jun 08, 2010 at 15:41 UTC | |
by JavaFan (Canon) on Jun 08, 2010 at 16:07 UTC | |
|
Re^3: String comparison "\x00" vs. "".
by BrowserUk (Patriarch) on Jun 08, 2010 at 11:39 UTC |