use Data::Dumper; use Algorithm::Diff qw(diff); @a=qw(a b c e h j l m n p); @b=qw(b c d e f j k l m r s t); print "@a\n"; print "@b\n"; my $diff=diff(\@a,\@b); while(<>){ chomp; my(@action)=split(/ /,$_); if($action[0] eq "+"){ splice(@a, $action[1], 0, $action[2]); } elsif($action[0] eq "-"){ splice(@a, $action[1],1); } print "@a\n"; print "@b\n"; } #### $VAR1 = [ [ [ '-', '0', 'a' ] ], [ [ '+', 2, 'd' ] ], [ [ '-', 4, 'h' ], [ '+', 4, 'f' ] ], [ [ '+', 6, 'k' ] ], [ [ '-', 8, 'n' ], [ '-', 9, 'p' ], [ '+', 9, 'r' ], [ '+', 10, 's' ], [ '+', 11, 't' ] ] ];