robert@0: #!C:/strawberry/perl/bin/perl.exe robert@0: robert@0: use strict; robert@0: use CGI; robert@0: robert@0: my $q = new CGI; robert@0: robert@0: print $q->header(); robert@0: robert@0: if ( defined $q->param('submit') or defined $q->param('Centigrade') or defined $q->param('Kelvin')) { robert@0: my $result = ""; robert@0: if ( defined $q->param('Centigrade') and $q->param('Centigrade') ne "") { robert@0: $result = $q->param('Centigrade') + 273.15; robert@0: } elsif ( defined $q->param('Kelvin') and $q->param('Kelvin') ne "" ) { robert@0: $result = $q->param('Kelvin') - 273.15; robert@0: } robert@0: print $result; robert@0: } else { robert@0: print &Show_Form(); robert@0: print &Show_Footer(); robert@0: } robert@0: robert@0: sub Show_Form { robert@0: my $html = ""; robert@0: $html .= < robert@0: Temperature Conversion robert@0: robert@0: robert@0:
robert@0: Temperature =
robert@0: degrees C
robert@0: degrees K
robert@0: robert@0:
robert@0:
robert@0: EOT robert@0: robert@0: return $html; robert@0: } robert@0: robert@0: sub Show_Footer { robert@0: print "\n"; robert@0: return; robert@0: }