|There's more than one way to do things|
Interesting that my last modification timed out. Did you run it with $i or $i+1?
Exactly as you posted it (c&p).
I just added print "i:$i j:$j"; to the bottom of the loop and it shows what happens:
Your concern about my use of $i+1 ignores the difference in the relative ordering of the ++$i increment in my version and yours. (The original.)
As for the possibility of out-by-one errors:
I'll trade the need to fix them, for the ability to make them; when the alternative is to rely upon the (unseen, unknown, uncontrollable, and possibly non-existent) generic optimisations of a declarative tool to convert a high-level -- and potentially completely broken -- abstract description of my problem into an efficient solution.
Had I opted for that approach, I would have settled on Damian's original solution. There would have been no incentive for him to improve it; or you to correct and improve yours.
The result would have been that my application for this; currently running on one of my 4 cores and projected to run for 7 to 10 days; would have projected to run for
Far too often people settle for the first solution on offer -- cpan -- and never consider the affect their choices have.
So yes, I'll willingly trade the need to correct out-by-one errors; for the ability to make them in the first place.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.