good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Loading file into memoryby monarch (Priest) |
on Aug 05, 2008 at 18:32 UTC ( [id://702441]=note: print w/replies, xml ) | Need Help?? |
Another method: store a hash with the key being the name and the value being the position in the file of the desired record. This will generally be slower when accessing records because the file itself must be interrogated, but it could potentially be faster as it minimises the risk of the file turning into swap memory (which is expensive to access at any rate). Your specification was rather unclear, so for the purposes of example code I will assume that you want a record given an $id (e.g. "daamaya") and a $name (e.g. "Daniel R. Amaya"). So I will construct a hash of ids that point to a hash of names that point to a position in the file containing the desired record. E.g.
In Section
Seekers of Perl Wisdom
|
|