line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::CA; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
501984
|
use warnings; |
|
4
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
184
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
86
|
|
5
|
4
|
|
|
4
|
|
1872
|
use Data::Section::Simple; |
|
4
|
|
|
|
|
2470
|
|
|
4
|
|
|
|
|
1745
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Locale::CA - two letter codes for province identification in Canada and vice versa |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.04 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Locale::CA; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $u = Locale::CA->new(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Returns the French names of the provinces if $LANG starts with 'fr' or |
26
|
|
|
|
|
|
|
# the lang parameter is set to 'fr' |
27
|
|
|
|
|
|
|
my $province = $u->{code2province}{$code}; |
28
|
|
|
|
|
|
|
my $code = $u->{province2code}{$province}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @province = $u->all_province_names; |
31
|
|
|
|
|
|
|
my @code = $u->all_province_codes; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Creates a Locale::CA object. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
6
|
|
|
6
|
1
|
3634
|
my $proto = shift; |
43
|
6
|
|
66
|
|
|
33
|
my $class = ref($proto) || $proto; |
44
|
|
|
|
|
|
|
|
45
|
6
|
100
|
|
|
|
21
|
return unless(defined($class)); |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
10
|
my %params; |
48
|
5
|
50
|
|
|
|
30
|
if(ref($_[0]) eq 'HASH') { |
|
|
50
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
%params = %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} elsif(scalar(@_) % 2 == 0) { |
51
|
5
|
|
|
|
|
13
|
%params = @_; |
52
|
|
|
|
|
|
|
} else { |
53
|
0
|
|
|
|
|
0
|
$params{'lang'} = shift; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
12
|
my $self = {}; |
57
|
5
|
|
|
|
|
7
|
my $data; |
58
|
5
|
|
|
|
|
45
|
my $lang = $params{'lang'}; |
59
|
5
|
100
|
66
|
|
|
68
|
if(defined($lang)) { |
|
|
100
|
|
|
|
|
|
60
|
1
|
50
|
33
|
|
|
7
|
if(($lang eq 'fr') || ($lang eq 'en')) { |
61
|
1
|
|
|
|
|
6
|
$data = Data::Section::Simple::get_data_section("provinces_$lang"); |
62
|
|
|
|
|
|
|
} else { |
63
|
0
|
|
|
|
|
0
|
die "lang can only be one of 'en' or 'fr', given $lang"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} elsif(defined($ENV{'LANG'}) && ($ENV{'LANG'} =~ /^fr/)) { |
66
|
1
|
|
|
|
|
8
|
$data = Data::Section::Simple::get_data_section('provinces_fr'); |
67
|
|
|
|
|
|
|
} else { |
68
|
3
|
|
|
|
|
14
|
$data = Data::Section::Simple::get_data_section('provinces_en'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
5
|
|
|
|
|
1288
|
my @line = split /\n/, $data; |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
|
|
15
|
for (@line) { |
74
|
60
|
|
|
|
|
125
|
my($code, $province) = split /:/; |
75
|
60
|
|
|
|
|
116
|
$self->{code2province}{$code} = $province; |
76
|
60
|
|
|
|
|
131
|
$self->{province2code}{$province} = $code; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
5
|
|
|
|
|
29
|
return bless $self, $class; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 all_province_codes |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns an array (not arrayref) of all province codes in alphabetical form. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub all_province_codes { |
89
|
1
|
|
|
1
|
1
|
561
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
2
|
return(sort keys %{$self->{code2province}}); |
|
1
|
|
|
|
|
13
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 all_province_names |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns an array (not arrayref) of all province names in alphabetical form |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub all_province_names { |
101
|
1
|
|
|
1
|
1
|
3495
|
my $self = shift; |
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
3
|
return(sort keys %{$self->{province2code}}); |
|
1
|
|
|
|
|
11
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 $self->{code2province} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is a hashref which has two-letter province names as the key and the long |
109
|
|
|
|
|
|
|
name as the value. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 $self->{province2code} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is a hashref which has the long name as the key and the two-letter |
114
|
|
|
|
|
|
|
province name as the value. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SEE ALSO |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Nigel Horne, C<< >> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 BUGS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * The province name is returned in C format. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * neither hash is strict, though they should be. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUPPORT |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
perldoc Locale::CA |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
You can also look for information at: |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * CPAN Ratings |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * Search CPAN |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Based on L - Copyright (c) 2002 - C<< $present >> Terrence Brannon. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2012-2020 Nigel Horne. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is released under the following licence: GPL2 |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; # End of Locale::CA |
171
|
|
|
|
|
|
|
__DATA__ |