I'm having some issues getting this coding ironed out. I know there's something I'm not doing right, but cannot figure out exactly what the something is.
Here's the html code:
<!WMS Temp Conversion>
<html>
<head><title>Washington Middle School Temperature Conversion</title></head>
<body>
<h3>Use the form below to convert the temperature of your choice.</h3><br />
<form action="http://localhost/cgi-bin/chap07/c07case1.cgi" method=post>
<p><input type="text" name="temp" size="6" maxlength="5"><br /><br />
<input type="radio" name="celToFah" value="celToFah">Convert from Celsius to Fahrenheit<br />
<input type="radio" name="fahToCel" value="fahToCel">Convert from Fahrenheit to Celsius</p>
<input type="submit" value="Convert">
</form>
</body>
</html>
and here's the perl script:
#!C:/Perl/bin/perl.exe
#c07case1.cgi --Temp Conversion
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use strict;
#variables
my ($temp, $celToFah, $fahToCel, $fahConversion, $celConversion);
$temp = param('temp');
#calculate
if $celToFah eq "true" {
convertFromCel();
$fahConversion = $temp * 9 / 5 + 32;
}
else {
convertFromFah();
$celConversion = ($temp - 32) * 5 / 9;
}
exit;
convertFromCel {
print "<html>\n";
print "<head><title>Conversion from Celsius</title></head>\n\n";
print "<body>\n";
print "<h3>$temp degrees Celsius converts to $fahConversion degrees Fahrenheit.</h3>\n";
print "</body>\n";
print "</html>";
}
convertFromFah {
print "<html>\n";
print "<head><title>Conversion from Fahrenheit</title></head>\n\n";
print "<body>\n";
print "<h3>$temp degrees Fahrenheit converts to $celConversion degrees Celsius.</h3>\n";
print "</body>\n";
print "</html>";
}