foreach SCALAR ( LIST ) { STATEMENTS; }Each time through the loop, SCALAR is assigned the next element in the LIST, and the STATEMENTS are executed.
foreach $instrument ("violin","viola","cello","bass") { print($instrument," is lighter than a \n"); } print("harp\n");
The National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign
johnsonb@ncsa.uiuc.edu
Last modified: June 19, 1997