Jump to content

Perl Programming/Keywords/continue

From Wikibooks, open books for an open world
Previous: connect Keywords Next: CORE

The continue keyword

[edit | edit source]

continue is a flow-control statement, if followed by a BLOCK. In a BLOCK or BLOCK, each time before the conditional is to be evaluated, contents of BLOCK are executed. So, it can be used to increment a loop variable even after a next statement (that resembles to the continue statement of C and other languages).

The BLOCK may contain last, next, or redo commands, where last and redo show the same behaviour as if they had been called in the main block.

Syntax

[edit | edit source]
  continue BLOCK
  continue

Examples

[edit | edit source]
while (EXPRESSION) {
   ### possible redo
   do_something;
} continue {
   ### possible next
   do_something_else;
   # go back the top to re-check the EXPRESSION
}
### possible last call

See also

[edit | edit source]
Previous: connect Keywords Next: CORE