annotate scripts/convert_degrees.pl @ 10:3b52ac950753 boosterpack tip

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