next up previous contents
Next: The while/until statement Up: If/Unless statement Previous: If/Unless statement

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 )

For example (

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