File Coverage

blib/lib/Locale/AU.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 3 3 100.0
total 39 40 97.5


line stmt bran cond sub pod time code
1             package Locale::AU;
2              
3 4     4   496865 use warnings;
  4         37  
  4         135  
4 4     4   23 use strict;
  4         6  
  4         81  
5 4     4   1890 use Data::Section::Simple;
  4         2324  
  4         1054  
6              
7             =head1 NAME
8              
9             Locale::AU - abbreviations for territory and state identification in Australia and vice versa
10              
11             =head1 VERSION
12              
13             Version 0.01
14              
15             =cut
16              
17             our $VERSION = '0.01';
18              
19             =head1 SYNOPSIS
20              
21             use Locale::AU;
22              
23             my $u = Locale::AU->new();
24              
25             my $state = $u->{code2state}{$code};
26             my $code = $u->{state2code}{$state};
27              
28             my @state = $u->all_state_names;
29             my @code = $u->all_state_codes;
30              
31              
32             =head1 SUBROUTINES/METHODS
33              
34             =head2 new
35              
36             Creates a Locale::AU object.
37              
38             =cut
39              
40             sub new {
41 4     4 1 411 my $proto = shift;
42 4   66     28 my $class = ref($proto) || $proto;
43              
44 4 100       16 return unless(defined($class));
45              
46 3         6 my $self = {};
47              
48 3         15 my $data = Data::Section::Simple::get_data_section('states');
49              
50 3         757 my @line = split /\n/, $data;
51              
52 3         11 for (@line) {
53 24         55 my($code, $state) = split /:/;
54 24         52 $self->{code2state}{$code} = $state;
55 24         58 $self->{state2code}{$state} = $code;
56             }
57              
58 3         31 return bless $self, $class;
59             }
60              
61             =head2 all_state_codes
62              
63             Returns an array (not arrayref) of all state codes in alphabetical form.
64              
65             =cut
66              
67             sub all_state_codes {
68 1     1 1 595 my $self = shift;
69              
70 1         3 return(sort keys %{$self->{code2state}});
  1         12  
71             }
72              
73             =head2 all_state_names
74              
75             Returns an array (not arrayref) of all state names in alphabetical form
76              
77             =cut
78              
79             sub all_state_names {
80 1     1 1 2489 my $self = shift;
81              
82 1         3 return(sort keys %{$self->{state2code}});
  1         10  
83             }
84              
85             =head2 $self->{code2state}
86              
87             This is a hashref which has state abbreviations as the key and the long
88             name as the value.
89              
90             =head2 $self->{state2code}
91              
92             This is a hashref which has the long name as the key and the abbreviated
93             state name as the value.
94              
95             =head1 SEE ALSO
96              
97             L
98              
99             =head1 AUTHOR
100              
101             Nigel Horne, C<< >>
102              
103             =head1 BUGS
104              
105             =over 4
106              
107             =item * The state name is returned in C format.
108              
109             =item * neither hash is strict, though they should be.
110              
111             =item * Jarvis Bay Territory is not handled
112              
113             =back
114              
115             =head1 SUPPORT
116              
117             You can find documentation for this module with the perldoc command.
118              
119             perldoc Locale::AU
120              
121             You can also look for information at:
122              
123             =over 4
124              
125             =item * RT: CPAN's request tracker
126              
127             L
128              
129             =item * CPAN Ratings
130              
131             L
132              
133             =item * Search CPAN
134              
135             L
136              
137             =back
138              
139             =head1 ACKNOWLEDGEMENTS
140              
141             Based on L - Copyright (c) 2002 - C<< $present >> Terrence Brannon.
142              
143             =head1 LICENSE AND COPYRIGHT
144              
145             Copyright 2020 Nigel Horne.
146              
147             This program is released under the following licence: GPL2
148              
149             =cut
150              
151             1; # End of Locale::AU
152             __DATA__