Its worse then that... your tests do the same amount of abuse. Have you considered doing this with a closure?
sub getAnyAll
{
my $code = shift;
my $Any = sub {
my @A = @{$_[0]}; # I like to dereference early, it makes
my @B = @{$_[1]}; # the rest of the code more readable.
while( @A and @B )
{
return 1 if &$code( pop(@A), pop(@B) )
}
return 0
};
my $All = sub {
my @A = @{$_[0]};
my @B = @{$_[1]};
while( @A and @B )
{
return 0 unless &$code( pop(@A), pop(@B) )
}
return 1
};
return ( $Any, $All );
}
that's untested, but gives you the idea. By the way... poping arrays passed by reference might not be such a good idea either...
|