undef # evaluates to "" so it's false -- note, you may get a warni +ng "use of uninitialized value if you are using -w
I belive you can not get such a warning, an undefined value is always false without any warning when interpreted as a boolean.
From perlsyn, section Declarations (it's so well hidden):
A variable holds the undefined value ("undef") until it has been assigned a defined value, which is anything other than "undef". When used as a number, "undef" is treated as 0; when used as a string, it is treated as the empty string, ""; and when used as a reference that isn't being of an uninitialized value whenever you treat "undef" as a string or a number. Well, usually. Boolean contexts, such asare exempt from warnings (because they care about truth rather than definedness).my $a; if ($a) {}
In reply to Re: What is true and false in Perl?
by ambrus
in thread What is true and false in Perl?
by root
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |