Employ looping
Print a list of elements
  1. Create a new script with this code:

    #!/usr/bin/perl
    print "Content-Type: text/html \n\n";

    # This script demonstrates how to print
    # an array using a foreach loop.

    @AcmeCars = ("Ford","Dodge","Chevy");

    print "<pThe text array contains:</p>";

    foreach $thisCar (@AcmeCars){
    print "$thisCar<br>\n";
    }
  2. Save the script as printlist.pl in the PERLSCRIPTS folder.

Want ad-free tutorials like these for classroom use? Get them at Visilearn.com.