http://www.perlmonks.org?node_id=989792


in reply to Identical Arrays

Another option is to use Array::Compare, as it can handle alpha, numeric and alphanumeric array data:

use Modern::Perl; use Array::Compare; my @a = ( 1, 2, 3 ); my @b = ( 2, 3, 1 ); my @c = ( 1, 2, 4 ); my @d = qw/ a b c a /; my @e = qw/ a a b c /; my @f = qw/ 1 b c 1 /; my @g = qw/ 1 1 b c /; say 'The arrays are', ArraysIdentical( \@a, \@b ) ? ' ' : ' not ', 'id +entical.'; sub ArraysIdentical { Array::Compare->new()->perm( $_[0], $_[1] ) || 0; }

Output:

The arrays are identical.