in reply to hash to hash comparison on large files
trywhile(my ($key2,$value2)=each(%hash2)){ if($key1 eq $key2){
you can reduce some time.if(exists $hash2{$key1}){
UPDATE
is it a typing mistake
opening the same file twice?!open(FH,"file1.txt")or die "can not open file"; open(FH1,"file1.txt")or die "can not open file";
since
so#push(@allhits,$key1);
will iterate over nothing!.foreach(@allhits){
moreover you have to read file1 again to get first column of file1 to be written into file2, so better change(going by your method)
topush(@file1,$list1[1]."#".$list1[2],$list1[4]);
(Untested)push(@file1,$list1[1]."#".$list1[2],[$list1[4],$list1[0]]); and in my @val1=split("/",$value1); use my @val1=split("/",$value1->[0]); and in #push(@allhits,$key1); use push(@allhits,[$key1,$value1->[1]]);#(correction from 0 to 1) and in my($id,$location)=split("#",$_); use my($id,$location)=split("#",$_[0]); and in print "$_";. use print "@{$_}"; # to what you got to write.
I agree with moritz on
so use seek to move file pointer to the beginning after while loop endswhile(my $str=<FH1>){
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash to hash comparison on large files
by patric (Acolyte) on Apr 08, 2009 at 17:11 UTC |