While may refer to any of the following:
- 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);
- 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.
Related information
- How to create a computer program.
Do, Iteration, Loop, Programming terms