in reply to Incrementing the loop again.
Using a "magic" value like that sounds like a nasty hack to avoid an extra variable. Show us the context where the 2 * $i hack is important and we'll show you a cleaner way to achieve the goal.
As others have mentioned Perl offers a much cleaner for loop over a list: for my $index (0 .. 100) which makes the loop constraints clearer and less error prone. Adding a flag variable such as $hadEvent means the loop variable is just a loop variable and the intent of the "magic" is obvious, in fact not even magic any more.
|
|---|