line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Random; |
2
|
2
|
|
|
2
|
|
1150
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
47
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
48
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
71
|
|
3
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'random'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#@Override |
8
|
|
|
|
|
|
|
sub filter |
9
|
|
|
|
|
|
|
{ |
10
|
2
|
|
|
2
|
0
|
3
|
my( $self, $filter_manager, $value, $context ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
2
|
50
|
0
|
|
|
7
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
13
|
|
|
|
|
|
|
$context, |
14
|
|
|
|
|
|
|
sprintf("Argument must be an ARRAY ref, not %s (%s)" |
15
|
|
|
|
|
|
|
, $value // 'undef' |
16
|
|
|
|
|
|
|
, ref $value || 'SCALAR' |
17
|
|
|
|
|
|
|
) |
18
|
|
|
|
|
|
|
) if ref $value ne 'ARRAY'; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
43
|
return $value->[int(rand scalar @$value)]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |