Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Slurping BIG files into Hashes

by cciulla (Friar)
on Jun 18, 2003 at 17:51 UTC ( #266929=note: print w/ replies, xml ) Need Help??


in reply to Slurping BIG files into Hashes

I'd be tempted to do it thusly, as it appears that you're throwng away the value part:

while (<config>) { chomp; my ($key, $value) = /^(.{1,13})(.+)$/; $lookup{$key} = $value; }
...or, am I missing something?

Update: perldoc -f substr has shown me the light.
Update the Second: As has hardburn.


Comment on Re: Slurping BIG files into Hashes
Select or Download Code
Re: Re: Slurping BIG files into Hashes
by hardburn (Abbot) on Jun 18, 2003 at 17:55 UTC

    Regexen are almost always going to be slower than substr. Normally, I'd put a big notice here about premature optimization being the root of all something or other, but in this case we actually do need to optimize. Of course, benchmarks need to be done to be sure.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-09-21 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls