Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: Multiple Conditional Statements

by BillKSmith (Chaplain)
on Sep 12, 2013 at 04:07 UTC ( #1053644=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Multiple Conditional Statements
in thread Multiple Conditional Statements

There is a maximum of only ten comparisons. By your criteria, the OP had it right in the first place. The ternary operator, with the format from the book "Perl Best Practices", cleans it slightly.

my $match = $RB1 == $RB2 ? 1 : $RB1 == $WR1 ? 1 : $RB1 == $WR2 ? 1 : $RB1 == $TE1 ? 1 : $RB2 == $WR1 ? 1 : $RB2 == $WR2 ? 1 : $RB2 == $TE1 ? 1 : $WR1 == $WR2 ? 1 : $WR1 == $TE1 ? 1 : $WR2 == $TE1 ? 1 : 0 ;
UPDATE: Or even
my $match = $RB1 == $RB2 || $RB1 == $WR1 || $RB1 == $WR2 || $RB +1 == $TE1 || $RB2 == $WR1 || $RB2 == $WR2 || $RB2 == $TE1 || $WR1 == $WR2 || $WR1 == $TE1 || $WR2 == $TE1 ;
Bill


Comment on Re^5: Multiple Conditional Statements
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-10-30 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (207 votes), past polls