Artikel im Internet unter http://www.hidemail.de/blog/the-until-command-in-perl.shtml.
Donnerstag, 20.12.2007, 05:57:34 Uhr

until in Perl



The until-command repeats a block, until a expression is true.

A simple example:

$i=0;

until ($i==10){print "$i\n";
$i++;
}


This little example prints the numbers 0-9.

The use of next, last and redo is possible.

Is the expression of until true, before the first loop begins, the code-block will not be processed.
If you want, that the code-block is processed at least once, you can use the form do{} until();

$i=10;

do {print "$i\n";

} until ($i==10)


This example prints the 10, althoug $i is 10 from beginning. The loop is processed one time.

Be careful, until can become a endless loop very easy, in case the expression in (..) is never true.

Until is the part of while, which processes a code-block, as long as the expression is true.



Artikel im Internet unter http://www.hidemail.de/blog/the-until-command-in-perl.shtml.