I have two arrays of strings that I would like to compare for equality:
my @array1 = (\"part1\", \"part2\", \"part3\", \"part4\");
my @array2 = (\"part1\", \
If order and duplicate values do not matter but only values equality (i.e. set comparison), you could use Set::Scalar.
It overloads common operators such as ==
or !=
.
my @array1 = ("part1", "part2", "part3", "part4");
my @array2 = ("part1", "PART2", "part3", "part4");
if ( Set::Scalar->new(@array1) == Set::Scalar->new(@array2) ) {...}
Alternatively, there's also Algorithm::Diff and List::Compare.