File: convert_degrees.pl

package info (click to toggle)
libcgi-ajax-perl 0.707-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 1,669; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 969 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/perl -w

use strict;
use CGI;

my $q = new CGI;

print $q->header();

if ( defined $q->param('submit') or defined $q->param('Centigrade') or defined $q->param('Kelvin')) {
  my $result = "";
  if ( defined $q->param('Centigrade') and $q->param('Centigrade') ne "") {
    $result = $q->param('Centigrade') + 273.15;
  } elsif ( defined $q->param('Kelvin') and $q->param('Kelvin') ne "" ) {
    $result = $q->param('Kelvin') - 273.15;
  }
  print $result;
} else {
  print &Show_Form();
  print &Show_Footer();
}

sub Show_Form {
  my $html = "";
  $html .= <<EOT;
<HTML>
  <HEAD><title>Temperature Conversion</title>
</HEAD>
<BODY>
  <form>
  Temperature =<br>
  <input type="text" name="Centigrade" size="10"> degrees C<br>
  <input type="text" name="Kelvin" size="10"> degrees K<br>
  <input type="submit" name="submit" value="Convert">
  <input type="reset"><br>
  </form>
EOT

  return $html;
}

sub Show_Footer {
  print "</body></html>\n";
  return;
}