Basic HTML version of Foils prepared March 30 97

Foil 27 Control Structures -- for Statement (Chapter 4 of the Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


for ( beginning expression; endtest; doeachloop ) {
  • FOR statement-block;
  • }
is just like C and equivalent to:
beginning-expression;
while ( endtest) {
  • FOR statement-block;
  • doeachloop;
  • }
For example, we can print the numbers 1 through 10 with:
for ($index=1; $index <=10; $index++ ) {
  • print $index,"\n";
  • }



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997