in reply to (jeffa) Re: What does the ternary statement actually do?
in thread What does the ternary statement actually do?

At the risk of beating a dead horse:

The ternary expression is an expression, whereas the if equivalent is a statement.

In even more other words, the if statement cannot be used as a component of an expression while the ternary operator can.

So, this:

my $x = $is_true ? 'is true!' : 'is false';

may be considered a shorter way of saying this (note that the my $x; must appear outside of the if):

my $x; if ($is_true) { $x = 'is true!'; } else { $x = 'is false!'; }

But, one cannot always simply condense an arbitrary if statement into a ternary expression

-----[ BofA: 212 583-8077 David.Miller(AT)bofasecurities(DOT)com ]-----
David M. Miller                       | phone/FAX:         212 662-0715
Business Visions, Inc., Suite #8E     | cell:              917 952-1600
680 West End Ave, New York, NY  10025 | e-mail: dmmiller(AT)acm(DOT)org
--------------------------------------+--------------------------------
      Spam Resistant (replace '(AT)' => '@', and '(DOT)' => '.')