> $no or $false or $yes and $true and say "OK then" ;
>
> $no or $false or say "OK then" if $yes and $true ;

Thank you for your reply.

I know there are other ways to do it.  I've had no choice but to do it other 
ways in Perl5.

I don't think I have ever used that notation (outside of file open and 
close) - not because I don't know it, but because it puts the emphasis on the 
wrong values.  It also doesn't read very smoothly.

In the samples you gave I had to read the entire line to see what the outcome 
of the code is.  In code you either give emphasis to the condition or to the 
action that happens should the condition prove successful.  Generally 
speaking, if the condition is the most important thing I will put it in a 
normal if/unless block.

if ($no or $false) {
   die "Some horrible death" unless $i_should_not;
}

But if the action is more important then I tend use a modifier.

print_greeting("Hello") if $logged_in unless $asked_not_too;

Allowing for multiple nested modifiers allows the action to retain its 
significance.  After I sent the last email I came across a statement in the 
code I was working on that would have phrased better if I could use both an 
if and an unless.  These things do come up - we Perl 5 coders have just 
trained ourselves to do things another ways.

The biggest setback I see to nested modifiers is that the order of lexical 
scopes visually read on the screen are reversed in execution.  But that is 
already a problem with a single level statement modifier.  I don't think 
multiple levels introduces any more problem than is already there.

Plus - if there are multiple modifiers then Perl poetry can get even better.  
And everybody wins if Perl poetry is better. :)

say "I'm ok"
if $i_am_ok
if $you_are_ok
while $the_world_is_ok;

Paul

Reply via email to