in reply to Finding a match between two paired arrays

I would be awfully tempted just to use a hash, even if the arrays get updated such that the hash would need to be rebuilt each time:
unless (exists { map { $a[$_].$b[$_] => $_ } 0..$#a }->{$a.$b}) { do_something(); }
If the arrays stay the same, you only need to build the hash once:
%ab = map { $a[$_].$b[$_] => $_ } 0..$#a; ... unless (exists $ab{$a.$b}) { do_something() }

Replies are listed 'Best First'.
Re: Re: Finding a match between two paired arrays
by Anonymous Monk on Jan 08, 2004 at 18:24 UTC
    my @a = qw(1 11); my @b = qw(1a 2b); ($a,$b) = qw(11 a); print "Why am I printing?$/" unless (exists { map { $a[$_].$b[$_] => $ +_ } 0..$#a }->{$a.$b});

    Of course, if you can guarantee @a contains only numerals and @b contains no numerals, then your solution works as advertised. However, this solution does break down when either array can contain any character.

      Thanks for pointing that out. I was going to mention the limitation, but decided the OP's example was sufficiently exemplary.