Hi Shawn!

On Sat, 1 Jul 2017 11:32:30 -0400
Shawn H Corey <shawnhco...@gmail.com> wrote:

> On Sat, 1 Jul 2017 17:27:02 +0200
> hw <h...@gc-24.de> 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.
> 
> > 
> > + What is being printed here?  
> 
> !!$i which is !(!(0)) which is !(1) which is 0
> 

I suspect !1 returns an empty string in scalar context.

> > 
> > + How do you do what I intended in perl?
> >   
> 
> How do we know what you intend?
> 
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
http://shlomifishswiki.branchable.com/Self-Sufficiency/

I don’t believe in fairies. Oops! A fairy died.
I don’t believe in fairies. Oops! Another fairy died.
    — http://www.shlomifish.org/humour.html

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to