roibrodo has asked for the wisdom of the Perl Monks concerning the following question:

Hi again,

I would like to seek your help in optimizing a double loop which is in the heart of my program. I really need it to be as efficient as possible to cut on running times, since it is called many times.

The idea is this. I have a large array @arr of size up to 10^6. I then get "ranges" in this array e.g. {FROM=>25000 TO=>40000} and I need to ++ all the cells in the range. What I do now is something like:

my @arr= (0) x $length; while ( ... get range to process ...) { for (my $i=$range->{FROM}; $i<$range->{TO}; ++i) { $arr[$i]++; } }

Is there anything I can do to optimize this process? Assume "get range to process" is already optimized.