That way, $i can't be used outside the loop, and I consider that a goo
I agree that makes sense and I do it myself all the time, but sometimes it might not be what you want to do and it might not be good thing in which case even if you think you are changing the behavior, you are not.
But why are you using a loop over a fixed range instead of a loop from
+ 1 to $end anyway?
It was a small example not real code. Where it says "# do some useful stuff" there would be ... some useful stuff :-)