| 1 | package Geography::BrazilianStates; | ||||||||||||||
| 2 | 2 | ▶ | use 5.008001; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | our $VERSION = "0.01"; | |||||||||||||
| 7 | |||||||||||||||
| 8 | 2 | our $STATES = [ | |||||||||||||
| 9 | {name => 'Acre', abbreviation => 'AC', capital => 'Rio Branco', region => 'Norte'}, | ||||||||||||||
| 10 | {name => 'Alagoas', abbreviation => 'AL', capital => 'Maceió', region => 'Nordeste'}, | ||||||||||||||
| 11 | {name => 'Amapá', abbreviation => 'AP', capital => 'Macapá', region => 'Norte'}, | ||||||||||||||
| 12 | {name => 'Amazonas', abbreviation => 'AM', capital => 'Manaus', region => 'Norte'}, | ||||||||||||||
| 13 | {name => 'Bahia', abbreviation => 'BA', capital => 'Salvador', region => 'Nordeste'}, | ||||||||||||||
| 14 | {name => 'Ceará', abbreviation => 'CE', capital => 'Fortaleza', region => 'Nordeste'}, | ||||||||||||||
| 15 | {name => 'Distrito Federal', abbreviation => 'DF', capital => 'Brasília', region => 'Centro-Oeste'}, | ||||||||||||||
| 16 | {name => 'Espírito Santo', abbreviation => 'ES', capital => 'Vitória', region => 'Sudeste'}, | ||||||||||||||
| 17 | {name => 'Goiás', abbreviation => 'GO', capital => 'Goiânia', region => 'Centro-Oeste'}, | ||||||||||||||
| 18 | {name => 'Maranhão', abbreviation => 'MA', capital => 'São Luís', region => 'Nordeste'}, | ||||||||||||||
| 19 | {name => 'Mato Grosso', abbreviation => 'MT', capital => 'Cuiabá', region => 'Centro-Oeste'}, | ||||||||||||||
| 20 | {name => 'Mato Grosso do Sul', abbreviation => 'MS', capital => 'Campo Grande', region => 'Centro-Oeste'}, | ||||||||||||||
| 21 | {name => 'Minas Gerais', abbreviation => 'MG', capital => 'Belo Horizonte', region => 'Sudeste'}, | ||||||||||||||
| 22 | {name => 'Pará', abbreviation => 'PA', capital => 'Belém', region => 'Norte'}, | ||||||||||||||
| 23 | {name => 'Paraíba', abbreviation => 'PB', capital => 'João Pessoa', region => 'Nordeste'}, | ||||||||||||||
| 24 | {name => 'Paraná', abbreviation => 'PR', capital => 'Curitiba', region => 'Sul'}, | ||||||||||||||
| 25 | {name => 'Pernambuco', abbreviation => 'PE', capital => 'Recife', region => 'Nordeste'}, | ||||||||||||||
| 26 | {name => 'Piauí', abbreviation => 'PI', capital => 'Teresina', region => 'Nordeste'}, | ||||||||||||||
| 27 | {name => 'Rio de Janeiro', abbreviation => 'RJ', capital => 'Rio de Janeiro', region => 'Sudeste'}, | ||||||||||||||
| 28 | {name => 'Rio Grande do Norte', abbreviation => 'RN', capital => 'Natal', region => 'Nordeste'}, | ||||||||||||||
| 29 | {name => 'Rio Grande do Sul', abbreviation => 'RS', capital => 'Porto Alegre', region => 'Sul'}, | ||||||||||||||
| 30 | {name => 'Rondônia', abbreviation => 'RO', capital => 'Porto Velho', region => 'Norte'}, | ||||||||||||||
| 31 | {name => 'Roraima', abbreviation => 'RR', capital => 'Boa Vista', region => 'Norte'}, | ||||||||||||||
| 32 | {name => 'Santa Catarina', abbreviation => 'SC', capital => 'Florianópolis', region => 'Sul'}, | ||||||||||||||
| 33 | {name => 'São Paulo', abbreviation => 'SP', capital => 'São Paulo', region => 'Sudeste'}, | ||||||||||||||
| 34 | {name => 'Sergipe', abbreviation => 'SE', capital => 'Aracaju', region => 'Nordeste'}, | ||||||||||||||
| 35 | {name => 'Tocantins', abbreviation => 'TO', capital => 'Palmas', region => 'Norte'} | ||||||||||||||
| 36 | ]; | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 1 | ▶ | sub states { | ||||||||||||
|
Subroutine
states: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 39 | 1 | my $class = shift; | |||||||||||||
| 40 | 1 | return map { $_->{name} } @$STATES; | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | |||||||||||||||
| 43 | 1 | ▶ | sub abbreviations { | ||||||||||||
|
Subroutine
abbreviations: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 44 | 1 | my $class = shift; | |||||||||||||
| 45 | 1 | return map { $_->{abbreviation} } @$STATES; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 1 | ▶ | sub capitals { | ||||||||||||
|
Subroutine
capitals: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 49 | 1 | my $class = shift; | |||||||||||||
| 50 | 1 | return map { $_->{capital} } @$STATES; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | 1 | ▶ | sub regions { | ||||||||||||
|
Subroutine
regions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 54 | 1 | my $class = shift; | |||||||||||||
| 55 | 1 | my %uniq; | |||||||||||||
| 56 | 1 | return grep { !$uniq{$_}++ } map { $_->{region} } @$STATES; | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 2 | ▶ | sub abbreviation { | ||||||||||||
|
Subroutine
abbreviation: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 60 | 2 | my ($class, $name) = @_; | |||||||||||||
| 61 | 2 | for my $state(@$STATES) { | |||||||||||||
| 62 | 8 | ▶ | if ($name eq $state->{name}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 63 | 1 | return $state->{abbreviation}; | |||||||||||||
| 64 | } elsif ($name eq $state->{abbreviation}) { | ||||||||||||||
| 65 | 1 | return $state->{name}; | |||||||||||||
| 66 | } | ||||||||||||||
| 67 | } | ||||||||||||||
| 68 | } | ||||||||||||||
| 69 | |||||||||||||||
| 70 | 2 | ▶ | sub capital { | ||||||||||||
|
Subroutine
capital: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 71 | 2 | my ($class, $name) = @_; | |||||||||||||
| 72 | 2 | for my $state(@$STATES) { | |||||||||||||
| 73 | 8 | ▶ | if ($name eq $state->{name}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 74 | 1 | return $state->{capital}; | |||||||||||||
| 75 | } elsif ($name eq $state->{capital}) { | ||||||||||||||
| 76 | 1 | return $state->{name}; | |||||||||||||
| 77 | } | ||||||||||||||
| 78 | } | ||||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 2 | ▶ | sub region { | ||||||||||||
|
Subroutine
region: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 82 | 2 | my ($class, $name) = @_; | |||||||||||||
| 83 | 2 | my $regions = []; | |||||||||||||
| 84 | 2 | for my $state(@$STATES) { | |||||||||||||
| 85 | 31 | ▶ | if ($name eq $state->{name}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 86 | 1 | return $state->{region}; | |||||||||||||
| 87 | } elsif ($name eq $state->{region}) { | ||||||||||||||
| 88 | 7 | push @$regions, $state->{name}; | |||||||||||||
| 89 | } | ||||||||||||||
| 90 | } | ||||||||||||||
| 91 | 1 | return @$regions; | |||||||||||||
| 92 | } | ||||||||||||||
| 93 | |||||||||||||||
| 94 | 1 | ▶ | sub states_all { | ||||||||||||
|
Subroutine
states_all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 95 | 1 | my $class = shift; | |||||||||||||
| 96 | 1 | return $STATES; | |||||||||||||
| 97 | } | ||||||||||||||
| 98 | |||||||||||||||
| 99 | 2 | 1; | |||||||||||||
| 100 | __END__ | ||||||||||||||