code;
}
Here is an example that prints the numbers 1 through 100 (one per line):
for (i=1; i<=100; i++) {
display(i, '\n');
}
Note that after this loop is finished executing, the value of i is 101.This is because
the LoopExpression evaluates each iteration until LoopCondition becomes FALSE. In this
case, LoopCondition (
i <= 100) becomes FALSE only once
i
is assigned the value 101.
“foreach” Loops
foreach loops can be used to iterate across each element in an array.To iterate through all
items in an array, use this syntax, which will assign each value in the array to the variable
x:
foreach x (array) {
display(x, '\n');
}
You can also put each array index in an array or hash using a foreach loop and the
keys function:
foreach k (keys(array)) {
display ("array[", ...