perltutorial
root
while loops allow you to execute a group of statements so long as a statment still evaluates to true.<BR>
Here's a quick example;
<CODE>
$num=20;
while($num<30){
print "num is $num\n";
$num=$num+1;
}
this will print out
num is 20
num is 21
...
num is 29
</CODE>
<P>
then num is incremented to 30 which is no longer less than 30
so the code within the while statement is not executed and
execution jumps to the next statement outside of the while statement.
<P>
If you think you know all about while statements learn about his less popular brother [until loops|until].
<P>
<SMALL>
<B>Edit</B> Wed Aug 1 07:07:10 EDT 2001 - [Petruchio] Changed PRE tags to
CODE tags, added whitespace.
</SMALL>
<P>
<small>
<strong>Edit</strong> Mon Dec 02:27:42 EST 2004 - [Petruchio]
changed '$while' to 'while', because this <em>is</em> in our Tutorials
section, and should be accurate.
</small>