If you're only interested in matching what the elements are and not their order, all you have to do is copy them into a pair of sorted temporary arrays and then compare that those are identical. Something like:
sub compare_arrays {
my ($array1, $array2) = @_;
my @temp1 = sort @$array1;
my @temp2 = sort @$array2;
return 0 unless $#temp1 = $#temp2; # If number of elements is differ
+ent, they don't match
for my $i (0..$#temp1) {
return 0 unless $temp1[$i] eq $temp2[$i]; # Something's different
+, no match
}
return 1; # OK, they match.
}
(Note: Not tested.) |