line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Getdigit; |
2
|
2
|
|
|
2
|
|
1150
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
46
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
48
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
3
|
2
|
|
|
2
|
|
11
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'get_digit'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#@Override |
8
|
|
|
|
|
|
|
sub parse_parameters |
9
|
|
|
|
|
|
|
{ |
10
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
11
|
|
|
|
|
|
|
die $self->get_parse_error("no digit number specified") |
12
|
4
|
50
|
|
|
|
5
|
if not scalar @{$self->{'parameter'}}; |
|
4
|
|
|
|
|
14
|
|
13
|
4
|
|
|
|
|
7
|
$self->{'digit'} = $self->{'parameter'}->[0]; |
14
|
4
|
|
|
|
|
13
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#@Override |
18
|
|
|
|
|
|
|
sub filter |
19
|
|
|
|
|
|
|
{ |
20
|
4
|
|
|
4
|
0
|
8
|
my ($self, $filter_manager, $value, $context) = @_; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
13
|
my $digit = $self->{'digit'}->render($context); |
23
|
4
|
50
|
33
|
|
|
43
|
if( |
|
|
|
33
|
|
|
|
|
24
|
|
|
|
|
|
|
$value =~ /^\d+$/ |
25
|
|
|
|
|
|
|
and $digit =~ /^\d+$/ |
26
|
|
|
|
|
|
|
and $digit > 0 |
27
|
|
|
|
|
|
|
) |
28
|
|
|
|
|
|
|
{ |
29
|
4
|
100
|
|
|
|
9
|
if( length $value >= $digit ) |
30
|
|
|
|
|
|
|
{ |
31
|
3
|
|
|
|
|
9
|
$value = substr $value, -$digit, 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else |
34
|
|
|
|
|
|
|
{ |
35
|
1
|
|
|
|
|
3
|
$value = ''; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
16
|
return $value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |