in reply to Multiple Conditional Statements
Anytime I see repeating-variable names like $RBn, I immediately think that $RB should instead be, say, a list with n elements in it. And in this case, that maybe the root variable should be a hash with keys such as 'RB', 'TE', 'WR'.
When looking for dupes, and especially if the values are scalar or string, a hash can come in handy: you jump-out as soon as anything exists(), viz ... for illustration only ...
my $dupes = {}; for my $k (qw/RB TE WR/) { for my $n (qw/1 2 3 4 5/) { $n = $my_data->{$k}{$v}; return 'DUPLICATE FOUND' if exists($dupes->{$n}); $dupes->{$n} = 1; // DON'T CARE ANY VALUE WILL DO } } return 'NO DUPLICATES';
This example illustrates the use of a hash ($my_data) to store the values, and of a hash ($dupes) to find duplicates. The technique would not work so-good if the values being sought were floating point.)
|
---|
In Section
Seekers of Perl Wisdom