For may refer to any of the following:

  1. A loop statement in programming that performs predefined tasks while or until a predetermined condition is met. Below is an example of a for loop in Perl that prints “Computer Hope” five times.

for ($i = 1; $i < 6; $i++) { print “Computer Hope\n”; }

In the above example, the for loop first sets the variable $i to a value of 1. Each time it executes, the $i variable is increased by 1 and while the $i variable is less than 6, “Computer Hope” is printed to the screen.

  1. For is also a Windows command line command, see the for command page for information.

Like any loop, when creating a for loop make sure it contains an exit condition (e.g., counter) that prevents an endless loop.

  • See the DOS for command reference and DOS forfiles command reference for command syntax and options.
  • Information about the Linux version is available on our Linux for command page.
  • How to create a computer program.
  1. Linux command, see the for command page for further information about this command.

Do, Foreach, Iteration, Loop, Programming terms, While