sub compare_arrays { my ($array1, $array2) = @_; my @temp1 = sort @$array1; my @temp2 = sort @$array2; return 0 unless $#temp1 = $#temp2; # If number of elements is different, 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. }