| 1 | package Text::Transliterator; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '1.06'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 5 | my $class = shift; | |||||||||||||||||||||||||||
| 9 | 5 | my ($from, $to); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # first arguments : either a hashref, or a pair of strings | ||||||||||||||||||||||||||||
| 12 | 5 | ▶ | if ((ref $_[0] || '') eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $_[0] || ''
MC/DC100%1/1
ref $_[0] || ''
ref $_[0]
Truth table100%2/2
A
A= ref $_[0]
| |||||||||||||||||||||||||||||
| 13 | 3 | my $map = shift; | |||||||||||||||||||||||||||
| 14 | 3 | $from = join "", keys %$map; | |||||||||||||||||||||||||||
| 15 | 3 | $to = join "", values %$map; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | else { | ||||||||||||||||||||||||||||
| 18 | 2 | $from = shift; | |||||||||||||||||||||||||||
| 19 | 2 | $to = shift; | |||||||||||||||||||||||||||
| 20 | 2 | ▶ | defined $from and defined $to | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $from and defined $to
MC/DC0%0/2
defined $from and defined $to
defined $from
defined $to
Truth table33%1/3
A and B
A= defined $fromB= defined $to
| |||||||||||||||||||||||||||||
| 21 | or die 'Text::Transliterator->new($from, $to): invalid args'; | ||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # remaining arguments | ||||||||||||||||||||||||||||
| 25 | 5 | ▶ | my $modifiers = shift || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 26 | not @_ | ||||||||||||||||||||||||||||
| 27 | 5 | ▶ | or die 'Text::Transliterator->new(): too many args'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # build the coderef. | ||||||||||||||||||||||||||||
| 30 | # Returns the list of tr/../../ results. | ||||||||||||||||||||||||||||
| 31 | # In scalar context, returns the last item (for compatibility with the previous API) | ||||||||||||||||||||||||||||
| 32 | 5 | my $src = "sub {my \@l = map {tr[$from][$to]$modifiers} \@_; return wantarray ? \@l : \$l[-1]}"; | |||||||||||||||||||||||||||
| 33 | 5 | local $@; | |||||||||||||||||||||||||||
| 34 | 5 | ▶ | my $coderef = eval $src or die "Text::Transliterator: error in compiling the tr function: $@"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 5 | return $coderef; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | 1; # End of Text::Transliterator | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||