While may refer to any of the following:

  1. A while loop or repeat loop is a loop statement in programming that performs a pre-defined task repeatedly until a condition is met. For example, in the Perl code below, a while loop opens the file “file.txt.” While going through each of the lines in the file, the code prints them if they contain any lowercase or uppercase letters.

open (INPUT, “<file.txt”); while () { if ($_ =~ /[a-zA-Z]/) { print “$_”; } } close (INPUT);

  1. While is also a Linux command, see the while command page for further information about this command.

Like any loop, when creating a for loop make sure it contains a condition to exit the loop and prevent an endless loop.

  • How to create a computer program.

Do, Iteration, Loop, Programming terms