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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Insert row from file
by Hena (Friar) on Dec 31, 2004 at 12:04 UTC | |
Re^2: Insert row from file
by smbs (Acolyte) on Dec 31, 2004 at 15:32 UTC | |
Re^2: Insert row from file
by smbs (Acolyte) on Dec 31, 2004 at 22:52 UTC | |
Re^2: Insert row from file
by smbs (Acolyte) on Jan 06, 2005 at 20:38 UTC | |
by Gilimanjaro (Hermit) on Feb 04, 2005 at 11:16 UTC |
In Section
Seekers of Perl Wisdom