input.txt This is an example section. And the second line has structural science. jabb.txt eg example exp expand sect section sci science output.txt (required output) This is an eg sect. And the second line has structural sci. #### use strict; use warnings; open( ABB, '<', 'jabb.txt' ) or die "Couldn't open ABB.\n$!"; open( IN, '<', 'input.txt' ) or die "Couldn't open infile.\n$!"; open( OUT, '>', 'output.out' ) or die "Couldn't open outfile.\n$!"; my @myin = ; while(){ if(/(.*?)\t(.*?)\n/){ my $abb=$1; my $full=$2; print "@myin\n"; @myin = s/$full/$abb/g; } } print OUT "@myin\n";