degreeopts.html
<!degreeopts.html>
<html>
<head><title>Degree
CIS</title></head>
<body>
<h1>Degree
Options in CIS</h1>
<form
action="http://www.pgrocer.com/cgi-bin/data/degreeopts.cgi"
method=post>
<b>Which
option are you enrolled in?</b><br>
<input type=radio
name=option value=0>Webmaster<br>
<input type=radio
name=option value=1>Programming<br>
<input type=radio
name=option value=2>Networking<br>
<input type=radio
name=option value=3>Multimedia and the Internet<br>
<input type=radio
name=option value=4>Business Information Systems<br>
<input type=radio
name=option value=5>Information Systems Transfer<br>
<input type=radio
name=option value=6>Computer Science Transfer<br>
<input
type=submit value="Submit">
</form>
</body>
</html>
degreeopts.cgi
#!/usr/bin/perl
#degreeopts.cgi -
saves form data to a file and reports results
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($option,
@records);
my @options_total = (0,
0, 0, 0, 0, 0, 0);
#assign variables
$option =
param('option');
#save form data to a
file
open(FILEOUT,
">>", "totals.txt")
or die "file error: totals.txt. $!,
stopped";
print FILEOUT
"$option\n";
close(FILEOUT);
#read file and
accumulate totals in an array
open(FILEIN,
"<", "totals.txt")
or die "file error: totals.txt. $!,
stopped";
@records=<FILEIN>;
close(FILEIN);
#display contents of
array on screen
foreach my
$record(@records) {
chomp($record);
$options_total[$record]=
$options_total[$record]+1;
}
print
"<html><head><title>CIS Degree
Options</title><basefont=5></head>\n";
print
"<body>\n";
print "<div
align=center>\n";
print
"<h2>Information about degree options in the CIS
department.</h2>\n";
print
"<table width = 50% border=2>\n";
print
"<tr><td colspan=2>Number of students in CIS Degree
options:</td></tr>\n";
print
"<tr><td>Webmaster</td><td>$options_total[0]</td></tr>\n";
print
"<tr><td>Programming</td><td>$options_total[1]</td></tr>\n";
print
"<tr><td>Networking</td><td>$options_total[2]</td></tr>\n";
print
"<tr><td>Multimedia and the
Internet</td><td>$options_total[3]</td></tr>\n";
print
"<tr><td>Business Information
Systems</td><td>$options_total[4]</td></tr>\n";
print
"<tr><td>Information Systems Transfer</td><td>$options_total[5]</td></tr>\n";
print
"<tr><td>Computer Science
Transfer</td><td>$options_total[6]</td></tr>\n";
print
"</table>\n";
print
"</div></body></html>\n";
maillist.html
<!mailinglist.html>
<html>
<head><title>Mailing
List</title></head>
<body>
<h1>Mailing
List</h1>
<form
action="http://www.pgrocer.com/cgi-bin/data/maillist.cgi"
method=post>
Enter
Name:<br>
<input type=text
name=name size=25><br><br>
Enter
Address:<br>
<input type=text
name=stadr size=25><br><br>
Enter
City:<br>
<input type=text name=city
size=20><br><br>
Enter
State:<br>
<input type=text
name=state size=2<br><br>
Enter ZIP:
<input type=text
name=zip size=10<br>
<input
type=submit value="Submit">
<input type=reset
value="Reset">
</form>
</body>
</html>
maillist.cgi
#!/usr/bin/perl
#maillist.cgi -
saves name and address information to make a mailing list
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip);
#assign variables
$name =
param('name');
$stadr =
param('stadr');
$city =
param('city');
$state =
param('state');
$zip = param('zip');
#save form data to a
file
open(FILEOUT,
">>", "maillist.txt")
or die "file error: maillist.txt. $!,
stopped";
print FILEOUT
"$name, $stadr, $city, $state, $zip\n";
close(FILEOUT);
print
"<html><head><title>Record just
entered</title><basefont size=5></head>\n";
print
"<body>\n";
print "<div
align=center>\n";
print "$name,
$stadr, $city, $state, $zip\n";
print
"</div></body></html>\n";
maillistrd.cgi
#!/usr/bin/perl
#maillistrd.cgi -
reads the mail list file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr, $city,
$state, $zip, @records);
open(INF,
"<", "maillist.txt")
or die "file error: maillist.txt. $!,
stopped";
@records=<INF>;
close(INF);
print
"<html><head><title>Records on mail
list</title><basefont size=5></head>\n";
print
"<body>\n";
print
"<h1>Mailing list:</h1>\n";
foreach my $record
(@records) {
chomp($record);
($name, $stadr, $city, $state, $zip) =
split(/,/, $record);
print "$name, $stadr, $city,
$state, $zip<br>\n";
}
print
"</body></html>\n";
payroll.html
<!payroll.html>
<html>
<head><title>Mailing
List</title></head>
<body>
<h1>Mailing
List</h1>
<form
action="http://www.pgrocer.com/cgi-bin/data/payroll.cgi"
method=post>
Enter
Name:<br>
<input type=text
name=name size=25><br><br>
Enter
Address:<br>
<input type=text name=stadr
size=25><br><br>
Enter
City:<br>
<input type=text
name=city size=20><br><br>
Enter
State:<br>
<input type=text
name=state size=2<br><br>
Enter ZIP:
<input type=text
name=zip size=10<br><br>
Enter Job Type (S
for Salaried, F for Full Time Hourly, P for Part Time Hourly):
<input type=text
name=jobtype size=2><br><br>
Enter Job Code:
<input type=text
name=jobcode size=2><br><br>
Enter Pay Per Hour:
<input type=text
name=payperhr size=10>
or Enter Salary:
<input type=text
name=salary size=12><br><br>
<input
type=submit value="Submit">
<input type=reset
value="Reset">
</form>
</body>
</html>
payroll.cgi
#!/usr/bin/perl
#payroll.cgi - saves
name and address information to make a mailing list
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
#assign variables
$name =
param('name');
$stadr =
param('stadr');
$city =
param('city');
$state =
param('state');
$zip = param('zip');
$jobtype =
param('jobtype');
$jobcode =
param('jobcode');
$payperhr =
param('payperhr');
$salary =
param('salary');
#save form data to a
file
open(FILEOUT,
">>", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print FILEOUT
"$name, $stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr,
$salary\n";
close(FILEOUT);
print
"<html><head><title>Record just
entered</title><basefont size=5></head>\n";
print
"<body>\n";
print "<div
align=center>\n";
print "$name,
$stadr, $city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary\n";
print
"</div></body></html>\n";
payrollrd.cgi
#!/usr/bin/perl
#payrollrd.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/,/,$_);
print "$name<br>\n";
}
close(INF);
print
"</body></html>\n";
payrollsal.cgi
#!/usr/bin/perl
#payrollsal.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Salaried
Workers</title><basefont size=5></head>\n";
print
"<body>\n";
print
"<h1>Salaried Workers:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S") {
print "$name - Salaried -
$jobtype<br>\n";
}
}
close(INF);
print
"</body></html>\n";
payrollsal1.cgi
#!/usr/bin/perl
#payrollsal1.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Salaried
Workers</title><basefont size=5></head>\n";
print
"<body>\n";
print
"<h1>Salaried Workers:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S")
{
print "$name - Salaried -
$jobtype<br>\n";
}
else
{
print "$name - Hourly -
$jobtype<br>\n";
}
}
close(INF);
print
"</body></html>\n";
payrolljobcd.cgi
#!/usr/bin/perl
#payrolljobcd.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print "Content-type:
text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Employees</title><basefont
size=5></head>\n";
print
"<body>\n";
print
"<h1>Employees:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobcode == 1 )
{
print "$name - Job Type #1 -
$jobcode<br>\n";
}
else
{
print "$name - All Other Job
Types - $jobcode<br>\n";
}
}
close(INF);
print
"</body></html>\n";
payrollsalamt.cgi
#!/usr/bin/perl
#payrollsalamt.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr, $city,
$state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Employees</title><basefont
size=5></head>\n";
print
"<body>\n";
print
"<h1>Employees:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S")
{
if ($salary >= 50000)
{
print "$name - $salary -
Salary greater than
50000<br>\n";
}
else
{
print "$name - $salary - Salary
not greater than or equal to 50000<br>\n";
}
}
else
{
print "$name - $payperhr - Hourly
employee<br>\n";
}
}
close(INF);
print
"</body></html>\n";
payrollcom.cgi
#!/usr/bin/perl
#payrollcom.cgi -
reads the payroll file
use CGI::Carp
qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Employees</title><basefont
size=5></head>\n";
print
"<body>\n";
print "<h1>Employees:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S" and $salary
>= 50000)
{
print "$name - $salary -
Salary greater than
50000<br>\n";
}
else
{
print "$name - other
employees<br>\n";
}
}
close(INF);
print
"</body></html>\n";
payrollcom2or.cgi
#!/usr/bin/perl
#payrollcomor.cgi -
reads the payroll file
use CGI::Carp qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Employees</title><basefont
size=5></head>\n";
print
"<body>\n";
print
"<h1>Employees:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S")
{
print "$name - $jobtype -
$jobcode - jobtype = S<br>\n";
}
else
{
if ($jobcode == 1)
{
print "$name - $jobtype -
$jobcode - jobcode = 1<br>\n";
}
else
{
print "$name - other
employees<br>\n";
}
}
}
close(INF);
print
"</body></html>\n";
payrollcomor.cgi
#!/usr/bin/perl
#payrollcomor.cgi -
reads the payroll file
use CGI::Carp qw(fatalsToBrowser);
print
"Content-type: text/html\n\n";
use CGI
qw(:standard);
use strict;
#declare variables
my ($name, $stadr,
$city, $state, $zip, $jobtype, $jobcode, $payperhr, $salary);
open(INF,
"<", "payroll.txt")
or die "file error: payroll.txt. $!,
stopped";
print
"<html><head><title>Employees</title><basefont
size=5></head>\n";
print
"<body>\n";
print
"<h1>Employees:</h1>\n";
while(<INF>) {
chomp($_);
($name, $stadr, $city, $state, $zip,
$jobtype, $jobcode, $payperhr, $salary) = split(/, /,$_);
if ($jobtype eq "S" or $jobcode
== 1)
{
print "$name - $jobtype -
$jobcode - either S or 1<br>\n";
}
else
{
print "$name - other
employees<br>\n";
}
}
close(INF);
print
"</body></html>\n";