in reply to if and else

I think what you're asking is "how do I write a postfix if, with an else part?" The answer is a rare one in perl - "you can't".

The following are some alternatives, all equivalent. I have replaced your if(0) with a $test variable which is true 50% of the time.

use 5.010; #gives you 'say' my $test = rand > 0.5; # two postfix tests: say 'TRUE' if $test; say 'FALSE' if not $test; # a one-liner conventional if if($test) { say 'TRUE' } else { say 'FALSE' } # two lines, using 'and' and 'or': $test and say 'TRUE'; $test or say 'FALSE'; # a ternary (my favourite): say $test ? 'TRUE' : 'FALSE';


- Boldra