- or download this
# 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 & rol
+l";
some_subroutine( ref($foo) eq "ARRAY" ? $foo : [$foo] );
- or download this
# Not ok - ?: flow control
$bar eq "baz" ? $foo = "foo" : $bar = "baz";
- or download this
# Ok - if/else flow control
if ($bar eq "baz") {
...
} else {
$bar = "baz";
}
- or download this
# Ok - if/else flow control, if a bit verbose.
if ($bar eq "baz") {
...
} else {
$foo = "baz";
}