| 1 | package Acme::MetaSyntactic::Locale; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 24 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use Acme::MetaSyntactic (); # do not export metaname and friends | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 24 | ▶ | use Acme::MetaSyntactic::MultiList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 24 | ▶ | use List::Util qw( shuffle ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 24 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 24 | our @ISA = qw( Acme::MetaSyntactic::MultiList ); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 24 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | sub init { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # alias the older package variable %Locale to %MultiList | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 24 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 23 | ▶ | *{"$_[0]::Locale"} = \%{"$_[0]::MultiList"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 23 | ${"$_[0]::Separator"} = '_'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # call the parent class init code | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 23 | goto &Acme::MetaSyntactic::MultiList::init; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 96 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 24 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 96 | my $self = bless { @_, cache => [] }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # compute some defaults | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 96 | ▶ | if( ! exists $self->{category} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | $self->{category} = | ||||||||||||||||||||||||||||||||||||||||||
| 31 | exists $self->{lang} | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ? $self->{lang} | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 94 | ▶ | : $ENV{LANGUAGE} || $ENV{LANG} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
$ENV{"LANGUAGE"} or $ENV{"LANG"} or ""
$ENV{"LANGUAGE"} or $ENV{"LANG"}
MC/DC100%2/2
$ENV{"LANGUAGE"} or $ENV{"LANG"} or ""
$ENV{"LANGUAGE"}
$ENV{"LANG"}
Truth table100%3/3
A or B
A= $ENV{"LANGUAGE"}B= $ENV{"LANG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 94 | ▶ | if( !$self->{category} && $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->{"category"} and $^O eq "MSWin32"
MC/DC100%2/2
not $self->{"category"} and $^O eq "MSWin32"
not $self->{"category"}
$^O eq "MSWin32"
Truth table100%3/3
not(A) and B
A= not $self->{"category"}B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | eval { require Win32::Locale; }; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | $self->{category} = Win32::Locale::get_language() unless $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 96 | my $cat = $self->{category}; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # support for territories | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 96 | ▶ | if ( $cat && $cat ne ':all' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cat and $cat ne ":all"
MC/DC100%2/2
$cat and $cat ne ":all"
$cat
$cat ne ":all"
Truth table100%3/3
A and B
A= $catB= $cat ne ":all"
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 33 | ($cat) = $cat =~ /^([-A-Za-z_]+)/; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 33 | ▶ | $cat = lc( $cat || '' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cat || ''
MC/DC0%0/1
$cat || ''
$cat
Truth table50%1/2
A
A= $cat
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 while $cat | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 33 | ▶ | && !exists ${"$class\::MultiList"}{$cat} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$cat and not exists do {
"${class}::MultiList"
}->{$cat} and $cat =~ s/_?[^_]*$//
$cat and not exists do {
"${class}::MultiList"
}->{$cat}
MC/DC66%2/3
$cat and not exists do {
"${class}::MultiList"
}->{$cat} and $cat =~ s/_?[^_]*$//
$cat
not exists do {
"${class}::MultiList"
}->{$cat}
$cat =~ s/_?[^_]*$//
Truth table75%3/4
A and not(B) and C
A= $catB= not exists do {
"${class}::MultiList"
}->{$cat}C= $cat =~ s/_?[^_]*$//
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | && $cat =~ s/_?[^_]*$//; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # fall back to last resort | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 96 | ▶ | $self->{category} = $cat || ${"$class\::Default"}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$cat || ${"${class}::Default";}
MC/DC0%0/2
$cat || ${"${class}::Default";}
$cat
${"${class}::Default";}
Truth table66%2/3
A || B
A= $catB= ${"${class}::Default";}
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 96 | $self->_compute_base(); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 96 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 24 | *lang = \&Acme::MetaSyntactic::MultiList::category; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 24 | *languages = \&Acme::MetaSyntactic::MultiList::categories; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 24 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||||||||||||||||