in reply to comparing arrays

A few comments:

1. If you're just starting out, you might want to try this "by hand" -- it's not that hard to do and you'll learn more about Perl than by relying on an external module.

2. Are you trying to compare if the values of two arrays of equal length are the same? Or if one array contains any values not in the other? (I.e. does exact position matter?) I'm not sure if Array::Compare is what you want or if you want List::Compare. Array::Compare looks like it's for comparing two arrays of equal length only.

3. A quick skim of Array::Compare reveals this:

full_compare \@ARR1, \@ARR2 Do a full comparison between two arrays. Checks each individual column. In scalar context returns the number of + columns that differ (zero if the arrays are the same). In list conte +xt returns an list containing the indexes of the columns that differ +(an empty list if the arrays are the same).

I'd guess your @difference array has the indices where there are differences, so you can "get the values out" like this:

foreach my $i (@differences) { print "$array1[$i] is not equal to $array2[$i]\n"; }

There are other ways to use an array of indices to retreive values from an array, such as slices (see perldata) but the example above should get you started.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.