in reply to Insert row from file
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);
|
|---|