Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: hash to hash comparison on large files

by targetsmart (Curate)
on Apr 08, 2009 at 13:55 UTC ( [id://756338]=note: print w/replies, xml ) Need Help??


in reply to hash to hash comparison on large files

instead of
while(my ($key2,$value2)=each(%hash2)){ if($key1 eq $key2){
try
if(exists $hash2{$key1}){
you can reduce some time.

UPDATE
is it a typing mistake

open(FH,"file1.txt")or die "can not open file"; open(FH1,"file1.txt")or die "can not open file";
opening the same file twice?!

since

#push(@allhits,$key1);
so
foreach(@allhits){
will iterate over nothing!.

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)

push(@file1,$list1[1]."#".$list1[2],$list1[4]);
to
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.
(Untested)

I agree with moritz on

while(my $str=<FH1>){
so use seek to move file pointer to the beginning after while loop ends

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

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
    sooo sorry...its file1 for FH file handle and file2 for FH1 file handle. i changed from original filename to the sample file names that i had given as example. thats y :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://756338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found