in reply to What could be the exact usage of While - continue loop

A common usage of continue is to allow some loop-end code to execute even when next is used to provide an early exit from a loop iteration. Consider:

use warnings; use strict; for my $yodda (1 .. 4) { print "Odd is " and next if $yodda & 1; print "Even is "; } continue { print "$yodda\n"; }

Prints:

Odd is 1 Even is 2 Odd is 3 Even is 4

Often early exits are used to avoid excessive control structure nesting - especially of if controlled blocks


DWIM is Perl's answer to Gödel