Perl not of a string equals to? -
my $pass = !$message;
i came across perl code $message string , $pass suppose boolean value. checked as
ok ($pass, $test)
i confused not (!) of $message?
how tranlate boolean value?
empty string false , nonempty string true?
the !
unary logical negation operator. false strings ""
, "0"
. if such string negated logically, evaluates 1
. other strings true-ish. negation of these ""
(the empty string) or numerically 0
.
other false values undef
, number 0
.
therefore, ok ($pass, $test)
pass if $message
undefined, empty string, or zero.
Comments
Post a Comment