Perlの練習 2013-10-22-0118

#!usr/bin/env perl
#すぐわかるオブジェクト指向Perl p299-300より

use strict;
use warnings;

my ($a, $b, $c) = (3, 4, 5);
my $space = space($a, $b, $c);
print "$space\n";

sub space {
    my ($a, $b, $c) = @_;
    my $s = ($a + $b + $c) / 2;
    my $space = sqrt($s * ($s - $a) * ($s - $b) * ($s - $c));
    return $space;
}

実行結果:

6

OK!