in reply to Illogical logic statement
Hello fkento, and welcome to the Monastery!
From Truth and Falsehood:
The number 0, the strings '0' and "", the empty list (), and undef are all false in a boolean context. All other values are true.
So, since the string “false” is none of 0, '0', the empty string, the empty list, or undef, it is true in Perl.
Update: Sorry, misread the question. The answer lies in the distinction between the operators == and eq. The former is for numerical comparison, the latter for string equality. See Equality Operators.
12:43 >perl -E "say (('false' == 'true') ? 'same' : 'different');" same 12:43 >perl -E "say (('false' eq 'true') ? 'same' : 'different');" different 12:43 >
Hope that helps,
Athanasius <°(((>< contra mundum
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Illogical logic statement
by fkento (Acolyte) on Dec 01, 2012 at 02:41 UTC | |
by LanX (Saint) on Dec 01, 2012 at 02:44 UTC | |
by fkento (Acolyte) on Dec 01, 2012 at 02:46 UTC | |
by Jenda (Abbot) on Dec 01, 2012 at 12:44 UTC | |
by Anonymous Monk on Dec 01, 2012 at 12:54 UTC | |
by Laurent_R (Canon) on Dec 01, 2012 at 11:07 UTC |
In Section
Seekers of Perl Wisdom