comparison BoosterPack/scripts/convert_degrees.pl @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0d795f02a8bb
1 #!C:/strawberry/perl/bin/perl.exe
2
3 use strict;
4 use CGI;
5
6 my $q = new CGI;
7
8 print $q->header();
9
10 if ( defined $q->param('submit') or defined $q->param('Centigrade') or defined $q->param('Kelvin')) {
11 my $result = "";
12 if ( defined $q->param('Centigrade') and $q->param('Centigrade') ne "") {
13 $result = $q->param('Centigrade') + 273.15;
14 } elsif ( defined $q->param('Kelvin') and $q->param('Kelvin') ne "" ) {
15 $result = $q->param('Kelvin') - 273.15;
16 }
17 print $result;
18 } else {
19 print &Show_Form();
20 print &Show_Footer();
21 }
22
23 sub Show_Form {
24 my $html = "";
25 $html .= <<EOT;
26 <HTML>
27 <HEAD><title>Temperature Conversion</title>
28 </HEAD>
29 <BODY>
30 <form>
31 Temperature =<br>
32 <input type="text" name="Centigrade" size="10"> degrees C<br>
33 <input type="text" name="Kelvin" size="10"> degrees K<br>
34 <input type="submit" name="submit" value="Convert">
35 <input type="reset"><br>
36 </form>
37 EOT
38
39 return $html;
40 }
41
42 sub Show_Footer {
43 print "</body></html>\n";
44 return;
45 }