in reply to Difference between two arrays

As a suggestion, compare each element, starting at element 0 - as soon as you find a difference, you will know which element moved (untested)

@before = qw(1 2 3 4 5); @after = qw(1 2 4 5 3); for($n=0; $n <= $#before; $n++){ if($before[$n] <> $after[$n]){ print "Element $n changed\n"; last; } }
Tom Melly, tom@tomandlu.co.uk

Replies are listed 'Best First'.
Re^2: Difference between two arrays
by rafl (Friar) on Mar 22, 2006 at 15:07 UTC

    That won't work well in my case as the items can move forwards and backwards in the list. Also your solution only tells me which element changed and now how it changed.

    Cheers, Flo