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?
|
---|
In Section
Seekers of Perl Wisdom