.+?)($default_template_title)(.+?<\/h2>)/$1$article_title$3/s; # change the article title
}
else
{
####################################
####################################
# Read top HTML page template
$html_template_top = $html_template . "_top.html";
open(TOP, "<./templates/$html_template_top") or die "Cannot open file \'$html_template_top\' $!";
while ($line = )
{
$top .= $line;
}
close TOP;
$top =~ s/(.+?)($default_template_title)(.+?<\/h2>)/$1$article_title$3/s; # change the article title
####################################
####################################
# Read bottom HTML page template
$html_template_bottom = $html_template . "_bottom.html";
open(BOTTOM, "<./templates/$html_template_bottom") or die "Cannot open file \'$html_template_bottom\' $!";
while ($line = )
{
$bottom .= $line;
}
close BOTTOM;
}
####################################
####################################
print "$top\n";
####################################
####################################
#### MY PERL CODE COMES IN HERE ####
####################################
my $cgi = CGI->new;
my %param = map {$_ => scalar $cgi->param($_)} $cgi->param();
# for my $key (sort keys %param)
# {
# print join ": ", $key, $param{$key};
# print "
\n";
# }
#############
# INPUT PROCESSING
if (exists $param{'submit'})
{
$text = $param{'text'};
open(F, '<', \$text) or die "Cannot open character string from variable $!";
while ($line = )
{
chomp $line;
$line =~ s/\r$//; # removes Windows-style CR (carriage return)
undef($modifier);
if ($line =~ /^(\d+) .*(\d)([\-\+]?)$/)
{
$weight = $1;
$grade = $2;
$modifier = $3;
if ($modifier)
{
if ($modifier =~ /\+/)
{
$modifier = 0.25;
}
elsif ($modifier =~ /\-/)
{
$modifier = -0.25;
}
else
{
$modifier = 0;
}
}
else
{
$modifier = 0;
}
$grade += $modifier;
$grade_sum += $weight * $grade;
$weight_sum += $weight;
}
}
close F;
if ($weight_sum > 0)
{
$weighted_average = $grade_sum/$weight_sum;
$weighted_average = sprintf("%.2f", $weighted_average);
print "Your Prymus weighted average is $weighted_average
\n";
}
}
else
{
# Submit button has not been pressed yet.
}
#############
# INPUT FORM
print "\n";
####################################
########## END OF MY CODE ##########
####################################
print "\n";
print "$bottom";
.+?)($default_template_title)(.+?<\/h2>)/$1$article_title$3/s; # change the article title
####################################
####################################
# Read bottom HTML page template
$html_template_bottom = $html_template . "_bottom.html";
open(BOTTOM, "<./templates/$html_template_bottom") or die "Cannot open file \'$html_template_bottom\' $!";
while ($line = )
{
$bottom .= $line;
}
close BOTTOM;
}
####################################
####################################
print "$top\n";
####################################
####################################
#### MY PERL CODE COMES IN HERE ####
####################################
my $cgi = CGI->new;
my %param = map {$_ => scalar $cgi->param($_)} $cgi->param();
# for my $key (sort keys %param)
# {
# print join ": ", $key, $param{$key};
# print "
\n";
# }
#############
# INPUT PROCESSING
if (exists $param{'submit'})
{
$text = $param{'text'};
open(F, '<', \$text) or die "Cannot open character string from variable $!";
while ($line = )
{
chomp $line;
$line =~ s/\r$//; # removes Windows-style CR (carriage return)
undef($modifier);
if ($line =~ /^(\d+) .*(\d)([\-\+]?)$/)
{
$weight = $1;
$grade = $2;
$modifier = $3;
if ($modifier)
{
if ($modifier =~ /\+/)
{
$modifier = 0.25;
}
elsif ($modifier =~ /\-/)
{
$modifier = -0.25;
}
else
{
$modifier = 0;
}
}
else
{
$modifier = 0;
}
$grade += $modifier;
$grade_sum += $weight * $grade;
$weight_sum += $weight;
}
}
close F;
if ($weight_sum > 0)
{
$weighted_average = $grade_sum/$weight_sum;
$weighted_average = sprintf("%.2f", $weighted_average);
print "Your Prymus weighted average is $weighted_average
\n";
}
}
else
{
# Submit button has not been pressed yet.
}
#############
# INPUT FORM
print "\n";
####################################
########## END OF MY CODE ##########
####################################
print "\n";
print "$bottom";
\n"; # } ############# # INPUT PROCESSING if (exists $param{'submit'}) { $text = $param{'text'}; open(F, '<', \$text) or die "Cannot open character string from variable $!"; while ($line =