line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
587
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Conveyor::Charset::ViaHash; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
19
|
$Data::Conveyor::Charset::ViaHash::VERSION = '1.103130'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Stage-based conveyor-belt-like ticket handling system |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1029
|
use charnames ':full'; |
|
1
|
|
|
|
|
44298
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
297
|
use parent 'Data::Conveyor::Charset'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->mk_constructor(qw(new))->mk_hash_accessors(qw(character_cache)) |
14
|
|
|
|
|
|
|
->mk_scalar_accessors(qw(valid_string_re_cache)); |
15
|
1
|
|
|
1
|
1
|
703
|
sub CHARACTERS { () } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_characters { |
18
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
19
|
2
|
50
|
|
|
|
15
|
unless ($self->character_cache_keys) { |
20
|
2
|
|
|
|
|
27
|
my $characters = $self->every_hash('CHARACTERS'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Convert the hash values to their actual Unicode character |
23
|
|
|
|
|
|
|
# equivalent. For defining a character, we accept Unicode character |
24
|
|
|
|
|
|
|
# names (the "..." part of the "\N{...}" notation) or hex code points |
25
|
|
|
|
|
|
|
# (indicated by a leading "0x"; useful for characters that don't have |
26
|
|
|
|
|
|
|
# a name). |
27
|
2
|
|
|
|
|
67
|
for (values %$characters) { |
28
|
52
|
100
|
|
|
|
169
|
next if utf8::is_utf8($_); # don't convert the already converted |
29
|
26
|
50
|
|
|
|
48
|
if (/^0x(.*)$/) { |
30
|
0
|
|
|
|
|
0
|
$_ = sprintf '%c' => hex($1); |
31
|
|
|
|
|
|
|
} else { |
32
|
26
|
|
|
|
|
57
|
$_ = sprintf '%c' => charnames::vianame($_); |
33
|
|
|
|
|
|
|
} |
34
|
26
|
|
|
|
|
16545
|
utf8::upgrade($_); |
35
|
|
|
|
|
|
|
} |
36
|
2
|
|
|
|
|
37
|
$self->character_cache(%$characters); |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
325
|
return $self->character_cache; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_character_names { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my %characters = $self->get_characters; |
44
|
0
|
|
|
|
|
|
my @names = keys %characters; |
45
|
0
|
0
|
|
|
|
|
wantarray ? @names : \@names; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_character_values { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my %characters = $self->get_characters; |
51
|
0
|
|
|
|
|
|
my @values = values %characters; |
52
|
0
|
0
|
|
|
|
|
wantarray ? @values : \@values; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub is_valid_string { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $string) = @_; |
57
|
0
|
0
|
|
|
|
|
unless (defined $self->valid_string_re_cache) { |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# escape critical characters so they're not interpreted as special |
60
|
|
|
|
|
|
|
# characters in the regex. |
61
|
0
|
0
|
|
|
|
|
my $chars = join '', |
62
|
0
|
|
|
|
|
|
map { m{^[\-.+*?()\[\]/\\]$} ? sprintf("\\%s", $_) : $_; } |
63
|
|
|
|
|
|
|
$self->get_character_values; |
64
|
0
|
|
|
|
|
|
$self->valid_string_re_cache(qr/^[$chars]+$/); |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
$string =~ $self->valid_string_re_cache; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |