Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: Multiple Conditional Statements

by BillKSmith (Priest)
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

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 about the Monastery: (6)
As of 2016-10-01 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (576 votes). Check out past polls.