use Devel::Peek;
my $f = (0 != 0);
my $e = q();
Dump($f);
Dump($e);
SV = PVNV(0x60003a5a0) at 0x600077cc8
REFCNT = 1
FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK)
IV = 0
NV = 0
PV = 0x6000b60c0 ""\0
CUR = 0
LEN = 10
SV = PV(0x60003c250) at 0x600077d70
REFCNT = 1
FLAGS = (POK,IsCOW,pPOK)
PV = 0x60009a810 ""\0
CUR = 0
LEN = 10
COW_REFCNT = 1
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
Thank you all.
It is more clear to me.
My conclusion is that false is not always 0...
But it is not a problem to take care of.
| [reply] |
| [reply] [d/l] [select] |
Why "porter" is not 0 ?
Why do you expect it to be 0? This is one way to get what you want:
use warnings;
use strict;
my $a = 6;
my $porter = (($a & 1) != 0) ? 1 : 0;
print "porter=$porter=\n";
__END__
porter=0=
Truth and Falsehood | [reply] [d/l] |
different values - including 0 - are considered false in Perl but not the other way round.
DB<9> use Data::Dump "dd"
DB<10> dd { true => !0, false => !1 }
{ false => "", true => 1 }
If you want Perl's internal value for false˛ to be mapped to 0 you have to do a $porter ||= 0
˛) NB: magical value! It is more than just an empty string to evaluate correctly in different contexts. | [reply] [d/l] [select] |
This doesn't answer your question, but is rather an attempt to help you do what it looks like you're after. I think what you are looking for is:
$ppp = defined $porter ? 'defined ' : 'undefined';
If you have perl 5.10 or better:
use 5.10;
$ppp = $porter;
$ppp //= 0;
Tommy
A mistake can be valuable or costly, depending on how faithfully you pursue correction
| [reply] [d/l] [select] |