<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 29, 2009, at 2:15 PM, Madison Kelly wrote:</div><br><blockquote type="cite"><div>Madison Kelly wrote:<br><blockquote type="cite">my $foo=$bar ? "bing" : "bang";<br></blockquote><blockquote type="cite">I am probably trying to extend what the above syntax was designed to address, but I am curious. I've got three strings I want to show based on the viewing user's credentials. I know I can use:<br></blockquote><blockquote type="cite">my $title="";<br></blockquote><blockquote type="cite">if ($a)<br></blockquote><blockquote type="cite">{<br></blockquote><blockquote type="cite"> $title="bing";<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite">elsif ($b)<br></blockquote><blockquote type="cite">{<br></blockquote><blockquote type="cite"> $title="bang";<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite">else<br></blockquote><blockquote type="cite">{<br></blockquote><blockquote type="cite"> $title="bong";<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite">But it's quite a bit more code.<br></blockquote><blockquote type="cite">Thanks all!<br></blockquote><blockquote type="cite">Madi<br></blockquote><br>Sorry to reply to my own question, but I did think of:<br><br>my $title="bong";<br>$title="bang" if $b;<br>$title="bing" if $a;<br><br>Though I would still be interested in another way more similar to:<br><br>my $foo=$bar ? "bing" : "bang";<br><br></div></blockquote><div><br></div>You can chain ?: for example in the debugger:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">main::(-e:1):</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Courier">        </font></span><font class="Apple-style-span" face="Courier">1</font></div><div><font class="Apple-style-span" face="Courier"> DB<1> $x = 0; $y = 0</font></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier"> DB<2> print $x ? 'bing' : $y ? 'bang' : 'bong'</font></div><div><font class="Apple-style-span" face="Courier">bong</font></div><div><font class="Apple-style-span" face="Courier"> DB<3> $x = 0; $y = 1</font></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier"> DB<4> print $x ? 'bing' : $y ? 'bang' : 'bong'</font></div><div><font class="Apple-style-span" face="Courier">bang</font></div><div><font class="Apple-style-span" face="Courier"> DB<5> $x = 1, $y = 0</font></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier"> DB<6> print $x ? 'bing' : $y ? 'bang' : 'bong'</font></div><div><font class="Apple-style-span" face="Courier">bing</font></div><div><br></div><div>Layout is left up to you :-)</div><div><br></div><div>Mike</div><br><blockquote type="cite"><div>Madi<br>_______________________________________________<br>toronto-pm mailing list<br><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>http://mail.pm.org/mailman/listinfo/toronto-pm<br></div></blockquote></div><br><div apple-content-edited="true"><div><div>-- </div><div><br></div><div>Mike Stok <<a href="mailto:mike@stok.ca">mike@stok.ca</a>></div><div><a href="http://www.stok.ca/~mike/">http://www.stok.ca/~mike/</a></div><div><br></div><div>The "`Stok' disclaimers" apply.</div><div><br></div><div><br></div></div><br></div><br></body></html>