Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Set a file's last access ...Turn a BLOCK into a TERM (Berikutnya)
Keywords related to control flow of your perl program

Optional trailing block in a while or foreach

Daftar Isi

  • continue BLOCK

  • continue

    When followed by a BLOCK, continue is actually aflow control statement rather than a function. Ifthere is a continue BLOCK attached to a BLOCK (typically in a while orforeach), it is always executed just before the conditional is about tobe evaluated again, just like the third part of a for loop in C. Thusit can be used to increment a loop variable, even when the loop has beencontinued via the next statement (which is similar to the C continuestatement).

    last, next, or redo may appear within a continueblock; last and redo behave as if they had been executed withinthe main block. So will next, but since it will execute a continueblock, it may be more entertaining.

    1. while (EXPR) {
    2. ### redo always comes here
    3. do_something;
    4. } continue {
    5. ### next always comes here
    6. do_something_else;
    7. # then back the top to re-check EXPR
    8. }
    9. ### last always comes here

    Omitting the continue section is equivalent to using anempty one, logically enough, so next goes directly backto check the condition at the top of the loop.

    When there is no BLOCK, continue is a function thatfalls through the current when or default block instead of iteratinga dynamically enclosing foreach or exiting a lexically enclosing given.In Perl 5.14 and earlier, this form of continue wasonly available when the "switch" feature was enabled.See feature and Switch Statements in perlsyn for moreinformation.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Set a file's last access ...Turn a BLOCK into a TERM (Berikutnya)