Perl Topics





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Perl Tutorial
Introduction Introduction
Installing Perl Installing Perl
Basics of Perl Basics of Perl
Scalar Variables Scalar Variables
Operators Operators
Control Structures Control Structures
Lists Lists
Array Array
Arrays Manipulation Arrays Manipulation
Arrays Functons Array Functions
Hash Hash
Hash Functions Hash Functions
String Functions String Functions
Regular Expression Regular Expression
Regular Expression Functions Regular Expression Functions
Numerical Functions Numerical Functions
List Functions List Functions
User Defined Function User Defined Function
File Handling File Handling
Forums Ask Your Doubts
Feedback Feedback
 





Perl WHILE Loop Function


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.

Other Links

web hosting