line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Math::PerfectChristmasTree; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21155
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
9
|
use Exporter; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
91
|
|
6
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
7
|
2
|
|
|
2
|
|
568294
|
use Math::Trig qw/pi/; |
|
2
|
|
|
|
|
52572
|
|
|
2
|
|
|
|
|
284
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
23
|
use vars qw/$VERSION @ISA @EXPORT_OK/; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
178
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
2
|
|
|
2
|
|
5
|
$VERSION = '0.02'; |
12
|
2
|
|
|
|
|
27
|
@ISA = qw/Exporter/; |
13
|
2
|
|
|
|
|
341
|
@EXPORT_OK = qw/calc_perfect_christmas_tree/; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub calc_perfect_christmas_tree { |
17
|
4
|
|
|
4
|
1
|
5889
|
my $tree_height = shift; |
18
|
|
|
|
|
|
|
|
19
|
4
|
100
|
|
|
|
15
|
if ($tree_height <= 0) { |
20
|
2
|
|
|
|
|
43
|
croak 'Tree height must be a number greater than zero.'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
5
|
my $pi = pi(); |
24
|
|
|
|
|
|
|
return ( |
25
|
2
|
|
|
|
|
21
|
'number_of_baubles' => _round(sqrt(17) / 20 * $tree_height), |
26
|
|
|
|
|
|
|
'tinsel_length' => 13 * $pi / 8 * $tree_height, |
27
|
|
|
|
|
|
|
'lights_length' => $pi * $tree_height, |
28
|
|
|
|
|
|
|
'star_or_fairy_height' => $tree_height / 10, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _round { |
33
|
2
|
|
|
2
|
|
3
|
my $value = shift; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
20
|
return int($value + 0.5); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |