411 REFERENCE · Wikibooks
Perl Programming/Keywords/while
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Perl when write Keywords
The while keyword
while is the statement that uses the EXPRESSION, called the condition, to loop through a block until the condition is true. It is the opposite of the until statement.
Syntax
while EXPRESSION
Examples
The code $a = 5;
print $a++ while $a < 10; prints the numbers 5 to 9 consecutively:
56789
The following two print statements $i = 5;
print $i++ while $i <= 10;
$j = 5;
print $j++ until $j > 10; return the same:
5678910
5678910
Perl when write Keywords