Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 wandering the Monastery: (5)
As of 2014-08-30 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (290 votes), past polls