Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: add/replace map result into existing hash

by DrHyde (Prior)
on Feb 19, 2014 at 11:41 UTC ( #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
Node Status?
node history
Node Type: note [id://1075442]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2019-07-22 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (22 votes). Check out past polls.

    Notices?