It's about what unary ! (bang operator) does to the operand
Here's the dissonance:
perl -E '$x=0; say "x=$x"; $x = !!$x; say "x=$x"'
x=0
x=
It behaves as you expect until you "bang" it twice.
I found a good explanation in the Camel:
"Unary ! performs logical negation, that is "not". The value
of a negated operand is true (1) if the operand is false
(numeric 0,string "0", the null string, or undefined) and
false ("") if the operand is true."
So double banging 0 yields "".
On Sat, Jul 1, 2017 at 12:54 PM, John Harris <[email protected]> wrote:
> What are these emails really about?
>
> On Jul 1, 2017 2:42 PM, "Chas. Owens" <[email protected]> wrote:
>
>>
>>
>> On Sat, Jul 1, 2017, 12:44 Shlomi Fish <[email protected]> wrote:
>>
>>> Hi Shawn!
>>>
>>> On Sat, 1 Jul 2017 11:32:30 -0400
>>> Shawn H Corey <[email protected]> wrote:
>>>
>>> > !!$i which is !(!(0)) which is !(1) which is 0
>>> >
>>>
>>> I suspect !1 returns an empty string in scalar context.
>>>
>>
>> !1 returns PL_sv_no (an internal scalar variable). It is a dualvar that
>> contains the empty string, the int 0 and the double 0.0. depending on the
>> context the value is used in, it will be one of those values.
>>
>> Many people think it is an empty string because the print function forces
>> string context.
>>
>>>