Any comments to this code.my $before = [qw(1 2 3 4 5 6 7 8 9 10)]; my $after = [qw(1 2 4 3 5 6 7 8 9 10)]; $k=0; for($i=0;$i<=@$before;$i++) { for($j=$k;$j<=@$after;$j++) { if(@$before[$i] eq @$after[$j] and $i==$j) { $i++;$k++; } if(@$before[$i] eq @$after[$j] and $i!=$j) { print "element @$before[$i] is moved to the position ",$j ++1; $i=@$before+1; last; } } } __DATA__ element 3 is moved to the position 4
In reply to Re^2: Difference between two arrays
by Anonymous Monk
in thread Difference between two arrays
by rafl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |