line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BusyBird::Filter; |
2
|
2
|
|
|
2
|
|
14832
|
use strict; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
63
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
52
|
|
4
|
2
|
|
|
2
|
|
7
|
use Exporter qw(import); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
51
|
|
5
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
122
|
|
6
|
2
|
|
|
2
|
|
1185
|
use Storable qw(dclone); |
|
2
|
|
|
|
|
6012
|
|
|
2
|
|
|
|
|
584
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(filter_map filter_each filter_grep); |
9
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub filter_each { |
12
|
1
|
|
|
1
|
1
|
133
|
my ($func) = @_; |
13
|
1
|
50
|
|
|
|
4
|
croak "func parameter is mandatory" if not defined $func; |
14
|
1
|
50
|
|
|
|
4
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
15
|
|
|
|
|
|
|
return sub { |
16
|
1
|
|
|
1
|
|
3
|
my $statuses = shift; |
17
|
1
|
|
|
|
|
5
|
$func->($_) foreach @$statuses; |
18
|
1
|
|
|
|
|
497
|
return $statuses; |
19
|
1
|
|
|
|
|
4
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub filter_map { |
23
|
8
|
|
|
8
|
1
|
366
|
my ($func) = @_; |
24
|
8
|
50
|
|
|
|
21
|
croak "func parameter is mandatory" if not defined $func; |
25
|
8
|
50
|
|
|
|
23
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
26
|
|
|
|
|
|
|
return sub { |
27
|
24
|
|
|
24
|
|
4186
|
my $statuses = shift; |
28
|
24
|
|
|
|
|
44
|
return [ map { $func->(dclone($_)) } @$statuses ]; |
|
27
|
|
|
|
|
1283
|
|
29
|
8
|
|
|
|
|
29
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub filter_grep { |
33
|
4
|
|
|
4
|
1
|
4316
|
my ($func) = @_; |
34
|
4
|
50
|
|
|
|
10
|
croak "func parameter is mandatory" if not defined $func; |
35
|
4
|
50
|
|
|
|
10
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
36
|
|
|
|
|
|
|
return sub { |
37
|
4
|
|
|
4
|
|
10
|
my ($statuses) = @_; |
38
|
4
|
|
|
|
|
6
|
return [ grep { $func->($_) } @$statuses ]; |
|
16
|
|
|
|
|
43
|
|
39
|
4
|
|
|
|
|
16
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |