Computer Sciences Department logo

CS 368-1 (2011 Summer) — Day 2 Code Sample

The code from class is copied below.

Hello, World!

#!/usr/bin/perl

use strict;
use warnings;

# Everyone's first Perl program
print "Hello, world!\n";

Temperature Conversion

#!/usr/bin/perl

use strict;
use warnings;

print "Today's temp? ";
chomp(my $input_temp = <STDIN>);

my $temp_in_c = ($input_temp - 32) * 5 / 9;

print "Today's temp in F is $input_temp.\n";
print "Today's temperature will be $temp_in_c\n";