<?xml version="1.0" encoding="windows-1252"?>
<node id="948" title="while loops" created="1999-11-04 23:22:54" updated="2005-08-15 14:51:30">
<type id="956">
perltutorial</type>
<author id="113">
root</author>
<data>
<field name="doctext">
while loops allow you to execute a group of statements so long as a statment still evaluates to true.&lt;BR&gt;
Here's a quick example;
&lt;CODE&gt;
$num=20;
while($num&lt;30){
   print "num is $num\n";
   $num=$num+1;
}

this will print out
num is 20
num is 21
...
num is 29
&lt;/CODE&gt;
&lt;P&gt;
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.
&lt;P&gt;
If you think you know all about while statements learn about his less popular brother [until loops|until].
&lt;P&gt;
&lt;SMALL&gt;
  &lt;B&gt;Edit&lt;/B&gt; Wed Aug  1 07:07:10 EDT 2001 - [Petruchio] Changed PRE tags to 
  CODE tags, added whitespace.
&lt;/SMALL&gt;
&lt;P&gt;
&lt;small&gt;
  &lt;strong&gt;Edit&lt;/strong&gt; Mon Dec  02:27:42 EST 2004 - [Petruchio]
  changed '$while' to 'while', because this &lt;em&gt;is&lt;/em&gt; in our Tutorials
  section, and should be accurate.
&lt;/small&gt;</field>
</data>
</node>
