Mercurial > boosterpack
view scripts/convert_degrees.pl @ 9:9652dc713ba6 boosterpack
working on adding to rlmcintyre.com
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 26 Jun 2010 20:06:08 -0400 |
parents | 477258d09353 |
children |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe3 use strict;4 use CGI;6 my $q = new CGI;8 print $q->header();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 }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 EOT39 return $html;40 }42 sub Show_Footer {43 print "</body></html>\n";44 return;45 }