line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BusyBird::Filter; |
2
|
2
|
|
|
2
|
|
14980
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
6
|
use Exporter qw(import); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
45
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
114
|
|
6
|
2
|
|
|
2
|
|
1151
|
use Storable qw(dclone); |
|
2
|
|
|
|
|
5724
|
|
|
2
|
|
|
|
|
629
|
|
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
|
146
|
my ($func) = @_; |
13
|
1
|
50
|
|
|
|
4
|
croak "func parameter is mandatory" if not defined $func; |
14
|
1
|
50
|
|
|
|
3
|
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
|
|
|
|
|
4
|
$func->($_) foreach @$statuses; |
18
|
1
|
|
|
|
|
447
|
return $statuses; |
19
|
1
|
|
|
|
|
5
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub filter_map { |
23
|
8
|
|
|
8
|
1
|
404
|
my ($func) = @_; |
24
|
8
|
50
|
|
|
|
20
|
croak "func parameter is mandatory" if not defined $func; |
25
|
8
|
50
|
|
|
|
22
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
26
|
|
|
|
|
|
|
return sub { |
27
|
24
|
|
|
24
|
|
3887
|
my $statuses = shift; |
28
|
24
|
|
|
|
|
40
|
return [ map { $func->(dclone($_)) } @$statuses ]; |
|
27
|
|
|
|
|
1294
|
|
29
|
8
|
|
|
|
|
29
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub filter_grep { |
33
|
4
|
|
|
4
|
1
|
4111
|
my ($func) = @_; |
34
|
4
|
50
|
|
|
|
10
|
croak "func parameter is mandatory" if not defined $func; |
35
|
4
|
50
|
|
|
|
9
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
36
|
|
|
|
|
|
|
return sub { |
37
|
4
|
|
|
4
|
|
10
|
my ($statuses) = @_; |
38
|
4
|
|
|
|
|
5
|
return [ grep { $func->($_) } @$statuses ]; |
|
16
|
|
|
|
|
42
|
|
39
|
4
|
|
|
|
|
16
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |