| 1 | package Locale::AU; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 6 | ▶ | use Data::Section::Simple; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 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.02 | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 6 | our $VERSION = '0.02'; | |||||||||||||||||||
| 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 | Can be called both as a class method (Locale::AU->new()) and as an object method ($object->new()). | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 5 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 43 | 5 | my $proto = shift; | |||||||||||||||||||
| 44 | 5 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition66%2/3
ref $proto || $proto
MC/DC50%1/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | # If the class is undefined, fallback to the current package name | ||||||||||||||||||||
| 47 | 5 | ▶ | if(!defined($class)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | # Use Locale::AU->new(), not Locale::AU::new() | ||||||||||||||||||||
| 49 | # Carp::carp(__PACKAGE__, ' use ->new() not ::new() to instantiate'); | ||||||||||||||||||||
| 50 | # return; | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | # FIXME: this only works when no arguments are given | ||||||||||||||||||||
| 53 | 1 | $class = __PACKAGE__; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | # Parse the data into bidirectional mappings | ||||||||||||||||||||
| 57 | 5 | my $self = {}; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 5 | my @line = split /\n/, Data::Section::Simple::get_data_section('states'); | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 5 | for (@line) { | |||||||||||||||||||
| 62 | 40 | my($code, $state) = split /:/; | |||||||||||||||||||
| 63 | # Map codes to states | ||||||||||||||||||||
| 64 | 40 | $self->{code2state}{$code} = $state; | |||||||||||||||||||
| 65 | # Map states to codes | ||||||||||||||||||||
| 66 | 40 | $self->{state2code}{$state} = $code; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 5 | return bless $self, $class; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head2 all_state_codes | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | Returns an array (not arrayref) of all state codes in alphabetical form. | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 2 | ▶ | sub all_state_codes { | ||||||||||||||||||
|
Subroutine
all_state_codes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 79 | 2 | my $self = shift; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 2 | return(sort keys %{$self->{code2state}}); | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head2 all_state_names | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | Returns an array (not arrayref) of all state names in alphabetical form | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 2 | ▶ | sub all_state_names { | ||||||||||||||||||
|
Subroutine
all_state_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 91 | 2 | my $self = shift; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 2 | return(sort keys %{$self->{state2code}}); | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =head2 $self->{code2state} | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | This is a hashref which has state abbreviations as the key and the long | ||||||||||||||||||||
| 99 | name as the value. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head2 $self->{state2code} | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | This is a hashref which has the long name as the key and the abbreviated | ||||||||||||||||||||
| 104 | state name as the value. | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head1 SEE ALSO | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | L<Locale::Country> | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =head1 AUTHOR | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | Nigel Horne, C<< <njh at bandsman.co.uk> >> | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =head1 BUGS | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =over 4 | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =item * The state name is returned in C<uc()> format. | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =item * neither hash is strict, though they should be. | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =item * Jarvis Bay Territory is not handled | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =back | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | =head1 SUPPORT | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | perldoc Locale::AU | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | You can also look for information at: | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =over 4 | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | =item * MetaCPAN | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | L<https://metacpan.org/dist/Local-AU> | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | =item * RT: CPAN's request tracker | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Local-AU> | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item * CPAN Testers' Matrix | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | L<http://matrix.cpantesters.org/?dist=Local-AU> | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =item * CPAN Testers Dependencies | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | L<http://deps.cpantesters.org/?module=Locale::AU> | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =back | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | Based on L<Locale::US> - Copyright (c) 2002 - C<< $present >> Terrence Brannon. | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | Copyright 2020-2025 Nigel Horne. | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | This program is released under the following licence: GPL2 | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | 6 | 1; # End of Locale::AU | |||||||||||||||||||
| 167 | __DATA__ | ||||||||||||||||||||