my @a1 = (...); my @a2 = (...); if ( @a1 == @a2 and do{local $"="\cA"; "@a1"} eq do{local $"="\cA"; "@a2"} ) { # They're the same }