File Coverage

blib/lib/Zodiac/Chinese.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Zodiac::Chinese;
2              
3 2     2   95826 use 5.008;
  2         9  
  2         106  
4 2     2   13 use strict;
  2         4  
  2         80  
5 2     2   23 use warnings;
  2         12  
  2         114  
6              
7 2     2   13 use base 'Exporter';
  2         2  
  2         1071  
8             our @EXPORT_OK = qw(chinese_zodiac);
9             our $VERSION = 1.00;
10              
11             my @direction = qw(yang yin);
12             my @element = (("metal") x 2, ("water") x 2, ("wood") x 2, ("fire") x 2, ("earth") x 2);
13             my @signs = qw(rat ox tiger rabbit dragon snake horse sheep monkey rooster dog pig);
14              
15             sub chinese_zodiac {
16 5     5 1 3310 my ($year,$month,$day) = @_;
17 5         9 my $zodiac;
18 5 100       17 if ($month > 1) {
19 4         20 $zodiac = $direction[$year % 2]." ".$element[$year % 10]." ".$signs[($year - 1924) % 12];
20             } else {
21 1         8 $zodiac = $direction[($year - 1) % 2]." ".$element[($year - 1) % 10]." ".$signs[(($year-1) - 1924) % 12];
22             }
23 5         99 return $zodiac;
24             }
25             1;
26             __END__