pmc2 has asked for the wisdom of the Perl Monks concerning the following question:
Could someone please explain to me why the following snippet prints "Yo helloBye" and not just "Yo hello"?
I thought the above example was equivalent to:perl -e '$x="\nYo "; print ($x ? $x.="hello" : $x.="Bye");'
which correctly prints "Yo hello". Any thoughts?perl -e '$x="\nYo "; if ($x) {print $x."hello";} else {print $x."Bye" +;}'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: ?: (conditional operator)
by Masem (Monsignor) on Aug 23, 2001 at 17:46 UTC | |
by pmas (Hermit) on Aug 23, 2001 at 18:56 UTC | |
Re: ?: (conditional operator)
by rchiav (Deacon) on Aug 23, 2001 at 17:38 UTC | |
by dragonchild (Archbishop) on Aug 23, 2001 at 17:41 UTC | |
Re: ?: (conditional operator)
by tune (Curate) on Aug 23, 2001 at 17:37 UTC | |
Re: ?: (conditional operator)
by busunsl (Vicar) on Aug 23, 2001 at 17:32 UTC | |
Re: ?: (conditional operator)
by Cine (Friar) on Aug 23, 2001 at 17:49 UTC | |
by echo (Pilgrim) on Aug 23, 2001 at 18:08 UTC |
Back to
Seekers of Perl Wisdom