line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Translit::String; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
80481
|
use strict; |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
117
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
96
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
2292
|
use English; |
|
4
|
|
|
|
|
16056
|
|
|
4
|
|
|
|
|
23
|
|
7
|
4
|
|
|
4
|
|
4029
|
use Error::Pure qw(err); |
|
4
|
|
|
|
|
30924
|
|
|
4
|
|
|
|
|
97
|
|
8
|
4
|
|
|
4
|
|
9365
|
use Getopt::Std; |
|
4
|
|
|
|
|
241
|
|
|
4
|
|
|
|
|
259
|
|
9
|
4
|
|
|
4
|
|
2083
|
use Lingua::Translit; |
|
4
|
|
|
|
|
156565
|
|
|
4
|
|
|
|
|
1414
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.07; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constructor. |
14
|
|
|
|
|
|
|
sub new { |
15
|
6
|
|
|
6
|
1
|
7929
|
my ($class, @params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Create object. |
18
|
6
|
|
|
|
|
21
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Object. |
21
|
6
|
|
|
|
|
26
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Run script. |
25
|
|
|
|
|
|
|
sub run { |
26
|
5
|
|
|
5
|
1
|
12
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Process arguments. |
29
|
5
|
|
|
|
|
28
|
$self->{'_opts'} = { |
30
|
|
|
|
|
|
|
'h' => 0, |
31
|
|
|
|
|
|
|
'r' => 0, |
32
|
|
|
|
|
|
|
't' => 'ISO/R 9', |
33
|
|
|
|
|
|
|
}; |
34
|
5
|
100
|
100
|
|
|
27
|
if (! getopts('hrt:', $self->{'_opts'}) || @ARGV < 1 |
|
|
|
66
|
|
|
|
|
35
|
|
|
|
|
|
|
|| $self->{'_opts'}->{'h'}) { |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
189
|
print STDERR "Usage: $0 [-h] [-r] [-t table] [--version]\n\t". |
38
|
|
|
|
|
|
|
"string\n\n"; |
39
|
2
|
|
|
|
|
25
|
print STDERR "\t-h\t\tPrint help.\n"; |
40
|
2
|
|
|
|
|
22
|
print STDERR "\t-r\t\tReverse transliteration.\n"; |
41
|
2
|
|
|
|
|
21
|
print STDERR "\t-t table\tTransliteration table (default ". |
42
|
|
|
|
|
|
|
"value is 'ISO/R 9').\n"; |
43
|
2
|
|
|
|
|
21
|
print STDERR "\t--version\tPrint version.\n"; |
44
|
2
|
|
|
|
|
11
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
3
|
|
|
|
|
178
|
$self->{'_string'} = $ARGV[0]; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Run. |
49
|
3
|
|
|
|
|
6
|
my $ret; |
50
|
3
|
|
|
|
|
15
|
eval { |
51
|
3
|
|
|
|
|
21
|
my $tr = Lingua::Translit->new($self->{'_opts'}->{'t'}); |
52
|
3
|
100
|
|
|
|
1459
|
if ($self->{'_opts'}->{'r'}) { |
53
|
2
|
100
|
|
|
|
9
|
if ($tr->can_reverse) { |
54
|
|
|
|
|
|
|
$ret = $tr->translit_reverse( |
55
|
1
|
|
|
|
|
22
|
$self->{'_string'}); |
56
|
|
|
|
|
|
|
} else { |
57
|
1
|
|
|
|
|
8
|
err 'No reverse transliteration.'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} else { |
60
|
1
|
|
|
|
|
5
|
$ret = $tr->translit($self->{'_string'}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
}; |
63
|
3
|
100
|
|
|
|
40046
|
if ($EVAL_ERROR) { |
64
|
1
|
|
|
|
|
6
|
err 'Cannot transliterate string.', |
65
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
66
|
|
|
|
|
|
|
} |
67
|
2
|
|
|
|
|
85
|
print "$ret\n"; |
68
|
2
|
|
|
|
|
12
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |