#!/usr/bin/perl -wT
use CGI':standard';
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $i;
my @range1;
my $top;
my $island;
#generates mime type
print header();
#generates basic html tags: doctype, html, head, title, body
print start_html(-title => "CGI.pm Library, Ranges & Enumerations");
#enumeration loop
print "<div>";
for $i (31, 62, 13, 84, 56)
{
print "$i ";
}
print "</div>";
#using ranges
@range1 = (1 .. 10);
$top = 25;
print "<div style='color:#009900;margin-top:10px;'>";
for $i (@range1, 15, 20 .. $top)
{
print "$i ";
}
print "</div>";
#enumeration loop with strings
print "<div style='color:#0000cc;margin-top:10px;'>";
for $island ('Maui', 'Nantucket', 'Fiji', 'Barbados', 'Corsica')
{
print "$island is my favorite island.<br>\n";
}
print "</div>";
#closes the body and html tags
print end_html();
CGI.pm Library, Ranges & Enumerations
31 62 13 84 56
1 2 3 4 5 6 7 8 9 10 15 20 21 22 23 24 25
Maui is my favorite island.
Nantucket is my favorite island.
Fiji is my favorite island.
Barbados is my favorite island.
Corsica is my favorite island.