Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 having an uproarious good time at the Monastery: (13)
As of 2014-12-29 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (193 votes), past polls