in reply to Testing if Two Arrays are Ordered in a Same Way

My algorithm: drop those element from the first array which are not in second, the resulting array should be the same as the second, which can be compared by joining the elements together. (not tested):
sub test_ordered{ my ($ar1,$ar2)= @_; my %array2; @array2{@{$ar2}} = 1; # a more perlish way? my @array1 = (); foreach (@{$ar1}){ push @array1, $_ if $array2{$_}; } return join(",", @array1) eq join(",",@{$ar2}); }