perl; getting a subset of hash keys based on a given value(s)

Peter plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Tue Mar 29 22:24:15 UTC 2005


On Tue, 29 Mar 2005, Madison Kelly wrote:

>  But that was taking over 2sec/dir. which meant my program would take up to 
> 7h to run this one task. The great guys and gals at TPM helped me get my head 
> around 'name => value' style hashes. So this style of hash is still somewhat 
> new to me so I may be missing the obvious. :p

Imho whenever you run into database problems, use a database. 
Implementing a database in Perl can be painful. Perl can interface to 
DB2, dbm, MySQL, PostreSQL and others. Choose one and use it. Imho it 
would be much faster to take a snapshot of the system using the 
equivalent of ls -lR and insert the result of that into a database, then 
operate on that database in Perl. Of course you know that your snapshot 
will not be up to date if the system is active when it is made. By 
telling the database to INDEX by certain keys you can actually issue 
your commands in SQL as you showed and it will be fairly fast (much less 
than 7 hours - a select on 4 indexed terms from the same table on 
PostgreSQL, from a 100,000 row table, on a 500MHz ancient machine takes 
well under a minute).

Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list