First of all, your 2 arrays must be written correctly.
@a = ("abc","def","efg","ghy","klm","ghn"); @b = ("def","efg","ghy","klm","ghn","klm");
Secondly, for arbitrary arrays (for example, arrays whose elements can be references to other data structures), you can use Data::Compare .
For arrays whose elements are scalar, you can perform a comparison using List::MoreUtils pairwise BLOCK ARRAY1 ARRAY2 , where BLOCK is your comparison routine. You can emulate pairwise (if you do not have access to the :: MoreUtils list) with:
if (@a != @b) { $equals = 0; } else { $equals = 1; foreach (my $i = 0; $i < @a; $i++) {
PS I'm not sure, but List :: Compare can always sort lists. I'm not sure that he can do pairwise comparisons.
DVK
source share