Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: add/replace map result into existing hash

by DrHyde (Prior)
on Feb 19, 2014 at 11:41 UTC ( [id://1075442]=note: print w/replies, xml ) Need Help??


in reply to add/replace map result into existing hash

Your for loop is effectively a map:

@l = map { ... } glob("*.gz")

Does that help?

BTW, the `shell stuff` will give you a scalar with embedded newlines, not a list of lines of text which is what I presume you want. You'll be better of using open(my $fh, '-|', "zcat $_") instead and read a line at a time, and translate the little sed snippet into perl.

Finally, why do you think that rewriting the code will save memory or make it faster? And do you know that it actually needs to be made faster? Have you profiled your code?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-19 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found