in reply to Insert row from file

This actually turned out almost exactly like Gilimanjaro's solution, but his is more efficient (if it works). I've included mine only because it may be more clear, and because it's tested.
use strict; use warnings; my ($in, $out, $key, $val, %hash); my $goodf = 'inp1.txt'; my $badf = 'inp2.txt'; my $outf = 'out.txt'; open($in, $goodf); while ($val = <$in>, $key = <$in>) { chomp($val, $key); $hash{$key} = $val; } close($in); open($in, $badf); open($out, ">$outf"); while ($key = <$in>) { chomp($key); print $out "$hash{$key}\n" if exists $hash{$key}; print $out "$key\n"; } close($in); close($out);