Anonymous user
Loops/While: Difference between revisions
m
→{{header|Perl}}: migrate content from Loop Structures
m (→{{header|Perl}}: migrate content from Loop Structures) |
|||
Line 391:
=={{header|Perl}}==
<lang perl>my $n = 1024;
while ($n > 0) {
print "$n\n";
$n >>= 1; # also acceptable: use integer; $n /= 2;
}</lang>
The <tt>until</tt> loop is equivalent to <tt>while (<i>not</i> condition)</tt>
<lang perl>my $n = 1024;
until ($n <= 0) {
print "$n\n";
$n /= 2;
}</lang>
|