in reply to conditional loop
{ last unless (my $once = $condition1) and $condition2; while(1) { # ... # ... last if $once or not $condition3; } }
Careful about the order of checks. Note that you might skip preserving the state in $once so long as $condition1 wouldn't change during an iteration of the loop and checking it doesn't have any side effects. However, you will have to duplicate the code at the bottom of the loop, so I believe the above form is still clearer in intent. It also has the benefit that it evaluates the expression only once.
Update: (Duh me.) So long as your statement 1..30 don't need next/last, you can and probably should use a do while:
{ last unless (my $once = $condition1) and $condition2; do { # ... # ... } while not $once and $condition3; }
Makeshifts last the longest.
|
|---|