in reply to Multiple Conditional Statements
If you like a more direct approach,
You could use grep in place of any (List::MoreUtils), but the name 'any' seems to convey the intent better.use strict; use warnings; use List::MoreUtils qw(any); my ($RB1, $RB2) = (1,2); my ($WR1, $WR2) = (3,4); my $TE1 = 1; my $match; my @a = \($RB1, $RB2, $WR1, $WR2, $TE1); for my $i (0..3){ $match |= any {${$a[$i]} == $$_} @a[$i+1 .. 4]; } print "No " if !$match; print "match\n";
Bill
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Multiple Conditional Statements
by BrowserUk (Patriarch) on Sep 11, 2013 at 15:14 UTC | |
by BillKSmith (Monsignor) on Sep 11, 2013 at 19:59 UTC | |
by BrowserUk (Patriarch) on Sep 11, 2013 at 21:23 UTC | |
by BillKSmith (Monsignor) on Sep 12, 2013 at 04:07 UTC |
In Section
Seekers of Perl Wisdom