http://qs321.pair.com?node_id=824399


in reply to Re^3: in search of a more elegant if then else
in thread in search of a more elegant if then else

This gets a little prettier in Perl 6, since it parses the inside of parens as a statement:
say (if $_ { 'fred' } else { 'bill' }) for 0..1;
Also, you can usually omit the curlies on a do, if the insides can terminate the whole statement...which it can't if there's a modifier, as above, so we'll invert it:
for 0..1 { say do if $_ { 'fred' } else { 'bill' } }
Of course, there's also the ternary operator, spelled ?? !!, if you want it...