3.) It seems like there would be some room for improvement on this code for efficiency to speed things along, but I can't seem to find it. Any suggestions would be very appreciated!!!Unless I misunderstood your code, you don't use %minhash for anything except creating @npanxxarray and %npanxxhash. Maybe it's possible to replace these three variables with only one? Let's see. Processing large flat files is usually done within a single loop which reads the file and does the computations, caching as little data as possible. Why not trim and count your values as you get them? Like this:
(code is untested, sorry)my %counts; while (<IN>) { next unless /^{.*$/; # skip non-matching lines my $min = (split ',')[1]; # get the value $counts{substr($min,0,6)} += 1; # found another one! } # at this point %counts is like your %npanxxhash, but without all the +temporary variables
Aside from that, child process can't modify variables in its parent, you would need to use threads and shared variables instead.
In reply to Re: Forking On Foreach Keys In Hash, Passing Hash To Sub, And Speed/Efficiency Recommendations
by aitap
in thread UPDATED: Forking On Foreach Keys In Hash, Passing Hash To Sub, And Speed/Efficiency Recommendations
by ImJustAFriend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |