Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added docs for C<while> and C<until>
  • Loading branch information
dha committed Sep 19, 2015
1 parent 2fda12d commit 8b9f93c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions lib/Language/control.pod
Expand Up @@ -452,6 +452,64 @@ is equivalent to the C-ish idiom:
loop (;;) {...}
=head2 while, until
The C<while> statement executes the block as long as its condition is
true. So
=begin code
my $x = 1;
while $x < 4 {
print $x++;
}
print "\n";
=end code
produces
=begin code
123
=end code
Similarly, the C<until> statement executes the block as long as the
expression is false.
=begin code
my $x = 1;
until $x > 3 {
print $x++;
}
print "\n";
=end code
again produces
=begin code
123
=end code
The condition for C<while> or C<until> can be parenthesized, but there
must be a space between the keyword and the opening parenthesis of the
condition.
Both C<while> and C<until> can be used as statement modifiers. E. g.
=begin code
$x++ while $x < 12
=end code
Also see C<repeat/while> and C<repeat/until> below.
=head2 repeat/while, repeat/until
Perl 5 allows one to apply a statement modifier to a C<do> block such that
Expand Down

0 comments on commit 8b9f93c

Please sign in to comment.