in reply to Comparing arrays

sort the array, join it with a null, then do a compare.
my $ary1 = join(/\0/, sort(@array1)); my $ary2 = join(/\0/, sort(@array2)); if ($ary1 eq $ary2) {....}

Replies are listed 'Best First'.
Re: Re: Comparing arrays
by CountZero (Bishop) on Dec 25, 2002 at 12:04 UTC

    But of course if you do a sort first then you loose the position of the elements in the array. If the position of the elements is not significant, this is a good solution.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law