http://www.perlmonks.org?node_id=842932


in reply to Optimizing a double loop

This might be faster than your inner loop:

splice @arr, $from, $to-$from+1, map 1+$_, @arr[$from..$to];

...but I haven't tested it. If we had a full runnable example, we could do some Benchmarking.