in reply to Difference between two arrays
The output would be:my $after = [qw(2 3 4 1 5 6 7 8 9 10)]; for (my $i = 1; $i < scalar($after); $i++){ my $diff = after->[$i-1] - $after->[$i]; if($diff > 0){ if($diff > $i){ printf "$after->[$i-1] moved to position %d\n",($i-1); } else{ print "$after->[$i] moved to position $i\n"; } last; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Difference between two arrays
by Anonymous Monk on Mar 23, 2006 at 05:36 UTC |