www.perl.com
Perl Programming
Arrays
  • Easy to iterate
    • foreach loop iterates over entire array
    • Good to localize the scalar to the loop

        my @fruits = qw(apple orange grape cranberry);

        foreach my $fruit (@fruits) {
	    print "We have $fruit juice in the refrigerator.\n";
        }
      

        Output:
        We have apple juice in the refrigerator.
        We have orange juice in the refrigerator.
        We have grape juice in the refrigerator.
        We have cranberry juice in the refrigerator.
      
Previous http://stuff.mit.edu/iap/perl/