How to Create a While Statement in Perl

Perl's while statement is a form of loop which iterates as long as a condition remains true.

Instructions

    • 1

      Initiate the while loop by specifying the while keyword.

    • 2

      Specify the condition for continuing the loop in parentheses following the while keyword:
      while ($ok)

    • 3

      Provide the statements to be executed each time through the loop within curly brackets:
      while ($ok)
      {
       :  $ok = ok();
      }

    • 4

      Place an optional continue clause after the loop body, to specify statements to be executed after the body but before the while condition is evaluated.

Related Searches:

Resources

Comments

You May Also Like

Related Ads

Featured