next up previous
Next: The while/until statement Up: Further Perl Programming Previous: Logical operators

The for statement

Just like in PASCAL we have loops.

The simplest is the for loop. It actually behaves like C's statement and is a little more complex than PASCAL -- it can do some more things.

The format of the for statement is:

for ( initialise_expr; test_expr; increment_expr )
  {
     statement(s);
  }

For example:

for ( $i = 1; $i <= 10; ++$i )
  { # count to 10
     print "$i\n";
  }



Dave Marshall
9/28/2001