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
What are these emails really about?
On Jul 1, 2017 2:42 PM, "Chas. Owens" wrote:
>
>
> On Sat, Jul 1, 2017, 12:44 Shlomi Fish wrote:
>
>> Hi Shawn!
>>
>> On Sat, 1 Jul 2017 11:32:30 -0400
>> Shawn H Corey wrote:
>>
>> > !!$i which is !(!(0)) which is !(1) which is 0
>> >
>>
>> I suspect !1 ret
On Sat, Jul 1, 2017, 12:44 Shlomi Fish wrote:
> Hi Shawn!
>
> On Sat, 1 Jul 2017 11:32:30 -0400
> Shawn H Corey 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
Hi hw!
Please see
http://www.shlomifish.org/philosophy/computers/netiquette/email/reply-to-list.html
.
On Sat, 1 Jul 2017 19:15:22 +0200 hw wrote:
> Shlomi Fish wrote:
> > Hi Shawn!
> >
> > On Sat, 1 Jul 2017 11:32:30 -0400
> > Shawn H Corey wrote:
> >
> >> On Sat, 1 Jul 2017 17:27:02 +0200
Hi Shawn!
On Sat, 1 Jul 2017 11:32:30 -0400
Shawn H Corey wrote:
> On Sat, 1 Jul 2017 17:27:02 +0200
> hw wrote:
>
> >
> > Hi,
> >
> > can someone please explain this:
> >
> >
> > perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'
> > i:
> >
> >
> > Particularly:
> >
>
On Sat, 1 Jul 2017 17:27:02 +0200
hw wrote:
>
> Hi,
>
> can someone please explain this:
>
>
> perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'
> i:
>
>
> Particularly:
>
>
> + Why doesn´t it print 1?
Because !!$i is zero
>
> + How is this not a bug?
Nope, no bug.
Hi,
can someone please explain this:
perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'
i:
Particularly:
+ Why doesn´t it print 1?
+ How is this not a bug?
+ What is being printed here?
+ How do you do what I intended in perl?
--
To unsubscribe, e-mail: beginners-unsu