in reply to Comparing two files and editing it.

It's a "diff" problem :)

#!/usr/bin/perl # http://perlmonks.org/?node_id=1136858 use Algorithm::Diff qw(traverse_sequences); use strict; use warnings; my $FileA = <<END; 111 abc 111 def 222 ghi 223 jkl 345 mno END my $FileB = <<END; 111 pqr 111 stu 111 vwx 222 yza 345 bcd END my @bigA = $FileA =~ /.*\n/g; my @bigB = $FileB =~ /.*\n/g; traverse_sequences( [ map /(...)/, @bigA ], [ map /(...)/, @bigB ], { DISCARD_A => sub { print $bigA[shift] }, DISCARD_B => sub { print $bigB[pop] }, } );