Perl operators, such as !those that return booleans, return a special value for false: it is used when used in a string context and 0 when used in a numeric context.
Therefore, when you print it, it is ", not" 0 ". But if you try to use it as a number, it does not give a warning how it does" ". For comparison:
perl -wle'$false = !1; print "string: ", $false, " number: ", 0+$false'
string: number: 0
and
perl -wle'$empty = ""; print "string: ", $empty, " number: ", 0+$empty'
Argument "" isn't numeric in addition (+) at -e line 1.
string: number: 0
source
share