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:
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:say (if $_ { 'fred' } else { 'bill' }) for 0..1;
Of course, there's also the ternary operator, spelled ?? !!, if you want it...for 0..1 { say do if $_ { 'fred' } else { 'bill' } }
In Section
Seekers of Perl Wisdom