All pastes #2047777 Raw Edit

Miscellany

public text v1 · immutable
#2047777 ·published 2011-04-18 13:49 UTC
rendered paste body
#!/usr/bin/perl

use warnings;
use strict;

print "Enter beginning temperature, ending temperature, and incremental value sepearated by commas: ";

while (my $line = <STDIN> )
{
    chomp($line);
    my ($start,$end,$increment) = split(/,/, $line);

    if ($start < -459.69 || $end < $start) {
        print STDERR "Error with data input, check your values and try again\r\n";
        next;
    }
    print "Fahrenheit\t\t\t\tCelcius\r\n";
    for (my $i=$start; $i<=$end; $i+=$increment)
    {
        print $i."\t\t\t\t" . FtoCelcius($i)."\r\n";
    }

}
sub FtoCelcius {
    my $f = shift;
    $f =~ s/[^\d\.]//g;
    return (5/9)*($f-32);
}