in reply to File Compare
Hi Cicatrix, see my updated answer below.
my %data_hash; open(my $fh, '<', "datafile.txt") or die $!; while(<$fh>){ $data_hash{$_} = 1; } close($fh); open(my $fh1, '<', "tmpfile.txt") or die $!; while(<fh1>){ if(defined($data_hash{$_})){ print"Line match"; #open new file in write mode and print line on file open(my $fh2, '>', "newfile.txt") or die $!; print $fh2 $data_hash{$_}; }else{ print"Line not match"; } } close($fh2); close($fh1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File Compare
by Cicatrix (Novice) on Mar 23, 2011 at 13:00 UTC |