http://qs321.pair.com?node_id=418511


in reply to Insert row from file

Untested code below, but I think it should do the trick...
# First build a hash we can use to look up lines (keyed on 2nd line) my %pairs; open A, "<A"; while(<A>) { $pairs{<A>}=$_ } close A; # We use a third file open C, ">C"; open B, "<B"; while(<B>) { # If this line matches a known 2nd line, insert it's 1st print C $pairs{$_} if exists $pairs{$_}; # Always print the original line print C $_; } close B; close C;