<?xml version="1.0" encoding="windows-1252"?>
<node id="1004827" title="Re: new way to code html?" created="2012-11-20 20:51:11" updated="2012-11-20 20:51:11">
<type id="11">
note</type>
<author id="333489">
muba</author>
<data>
<field name="doctext">
&lt;p&gt;&lt;c&gt;?:&lt;/c&gt; should really be used to let Perl choose one or another value based on the truthfullness of an expression, not as a flow control mechanism. If you want flow control, use &lt;c&gt;if&lt;/c&gt; and &lt;c&gt;else&lt;/c&gt;&lt;/p&gt;

&lt;c&gt;
# Ok - pick a value based on the value of $bar
$foo = $bar eq "baz" ? "foobaz" : "foobar";
print "I am the ", ($sex eq "male" ? "king" : "queen"), "of rock &amp; roll";
some_subroutine( ref($foo) eq "ARRAY" ? $foo : [$foo] );
&lt;/c&gt;&lt;c&gt;
# Not ok - ?: flow control
$bar eq "baz" ? $foo = "foo" : $bar = "baz";
&lt;/c&gt;&lt;c&gt;
# Ok - if/else flow control
if ($bar eq "baz") {                         
    $foo = "foo";
} else {
    $bar = "baz";
}
&lt;/c&gt;&lt;c&gt;
# Ok - if/else flow control, if a bit verbose.
if ($bar eq "baz") {                         
    $foo = "foo";
} else {
    $foo = "baz";
}
&lt;/c&gt;</field>
<field name="root_node">
1004820</field>
<field name="parent_node">
1004820</field>
</data>
</node>
