use Modern::Perl; my @one = ( 1, 2, 3 ); my @two = ( 2, 3, 1 ); my @three = ( 1, 2, 4 ); say identical( \@one, \@two ); # returns 1 say identical( \@one, \@three ); # returns 0 sub identical { my ( $first, $second ) = @_; return ((join chr(0), sort @$first) eq (join chr(0), sort @$second)) ? 1 : 0; }