File Coverage

blib/lib/Lingua/Postcodes.pm
Criterion Covered Total %
statement 19 19 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1 1     1   14142 use strict;
  1         1  
  1         36  
2              
3             package Lingua::Postcodes;
4             $Lingua::Postcodes::VERSION = '0.001'; # TRIAL
5 1     1   3 use warnings;
  1         1  
  1         20  
6 1     1   3 use utf8;
  1         8  
  1         3  
7              
8             # ABSTRACT: Returns the names of postcodes/zipcodes
9              
10 1     1   20 use base 'Exporter';
  1         1  
  1         202  
11             our @EXPORT = 'name';
12              
13             our %POSTCODES = (
14             AL => { EN => 'Post Code', AL => 'Kodi Postar' },
15             FR => { EN => 'Postal Code', FR => 'Code Postal' },
16             GB => { EN => 'Postcode', FR => '?' },
17             IE => { EN => 'Eircode', FR => '?' },
18             IN => { EN => 'PIN Code', FR => '?' },
19             RO => { EN => 'Postal Code', RO => 'Cod poČ™tal' },
20             US => { EN => 'Zip code', FR => '?' },
21             );
22              
23             sub name {
24 9     9 0 67 my $country_code = shift;
25 9 100       18 if ( @_ == 0 ) {
26 3 100       13 return undef unless exists $POSTCODES{$country_code};
27              
28 2         8 return $POSTCODES{$country_code}{'EN'};
29             }
30             else {
31 6         7 my $language = shift;
32 6 50       13 return undef unless exists $POSTCODES{$country_code}{$language};
33              
34 6         21 return $POSTCODES{$country_code}{$language};
35             }
36             }
37             1;
38              
39             __END__