Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Finding missing record between 2 files ?

by RMGir (Prior)
on Jan 06, 2011 at 12:52 UTC ( #880812=note: print w/replies, xml ) Need Help??


in reply to Re: Findding missing record between 2 files ?
in thread Findding missing record between 2 files ?

(fixed typo in subject)

As long as the files aren't large, that's fine, except that you're not finding keys present in file B but not in file A.

You're using 2 hashes where one would suffice, so you can cut your memory usage in half.

Pseudo code:

Process File A contents and store in %hash_one while(<FileB>) { # do whatever you need to to compute $key if (! exists $hash_one{$key}) { print "File B contains $key but File A does not\n"; } delete $hash_one{$key}; } # the keys left in %hash_one weren't in File B foreach(keys %hash_one) { print "File A contains $key, but File B does not\n"; }

Mike

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://880812]
help
Chatterbox?
[LanX]: according to wp: Londoners voted in a referendum in 1998 to create new governance structures for Greater London.
[LanX]: so it was the will of the people to take back control
[LanX]: ;)
[marto]: and you still can't get a decent cup of tea in that town
[davies]: The turnout, IIRC, was about 12%.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-12-15 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (442 votes). Check out past polls.

    Notices?