|
|
Tutorials

Perl

|
Topic |
What is While loop function in Perl programming?
|
|
Explanation |
|
The While loop function in Perl is used to execute statements till the condition becomes false.
Syntax:
While (expr1)
{
Statement to be executed
}
In the above syntax the code segment is executed till the "expr1" becomes false, here the iteration never stops
even the condition becomes false until it checks the "expr1".
Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
$c=0;
while($c<=5)
{
print "This is line".$c."<br>";
$c++;
}
Result:
This is line0
This is line1
This is line2
This is line3
This is line4
This is line5
In the above example when the value of $c becomes 6, the iteration continues till the "expr1" is checked and as the condition
is false the code execution is stopped.
|
|
A Note |
|
Simple introduction, basic CGI perl programming codes with examples.
Do send your feedback or suggestions on this tutorial.
This is a copyright content.
|
|
|
|