Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Perl Code Runs Extremely Slow

by TGI (Parson)
on Jun 15, 2006 at 20:46 UTC ( [id://555619]=note: print w/replies, xml ) Need Help??


in reply to Perl Code Runs Extremely Slow

Upon reviewing this thread, a new concern occurred to me. You may not be getting the results you want with this code. A hash only stores one value for each key,

For example, if your data looks like:

File 1:
a  1
b  2
c  3
d  4
a  5

File2:
a  10
b  11
c  20
c  12

Your output would be something like:

a  5  10
b  2  11
c  3  12
d  4

If you were looking for something like:

a  1   1
a  5  10
b  2  11
c  3  20
c  3  12
d  4
you'll need to make some decions about how you handle duplicate keys in your files.

If you need to keep all your data, I recommend reading the data structures cookbook.

You will also need to move your data out of RAM and onto a disk (DB_File is probably the easiest way), since you won't be overwriting your data. The RAM issues samtregar mentioned will become particularly acute. If you are going to be building complex data structures, MLDBM will work better for you than DB_File.

BTW, to create a hash tied to a DBM file, you can use:

my %file1; tie %file1, "DB_File", "file1.data" ;


TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found