line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BusyBird::Filter; |
2
|
2
|
|
|
2
|
|
24964
|
use v5.8.0; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
109
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
75
|
|
5
|
2
|
|
|
2
|
|
11
|
use Exporter 5.57 qw(import); |
|
2
|
|
|
|
|
45
|
|
|
2
|
|
|
|
|
88
|
|
6
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
179
|
|
7
|
2
|
|
|
2
|
|
1588
|
use Storable qw(dclone); |
|
2
|
|
|
|
|
7443
|
|
|
2
|
|
|
|
|
834
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(filter_map filter_each filter_grep); |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub filter_each { |
13
|
1
|
|
|
1
|
1
|
211
|
my ($func) = @_; |
14
|
1
|
50
|
|
|
|
5
|
croak "func parameter is mandatory" if not defined $func; |
15
|
1
|
50
|
|
|
|
5
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
16
|
|
|
|
|
|
|
return sub { |
17
|
1
|
|
|
1
|
|
5
|
my $statuses = shift; |
18
|
1
|
|
|
|
|
5
|
$func->($_) foreach @$statuses; |
19
|
1
|
|
|
|
|
818
|
return $statuses; |
20
|
1
|
|
|
|
|
8
|
}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub filter_map { |
24
|
8
|
|
|
8
|
1
|
562
|
my ($func) = @_; |
25
|
8
|
50
|
|
|
|
28
|
croak "func parameter is mandatory" if not defined $func; |
26
|
8
|
50
|
|
|
|
27
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
27
|
|
|
|
|
|
|
return sub { |
28
|
24
|
|
|
24
|
|
6257
|
my $statuses = shift; |
29
|
24
|
|
|
|
|
49
|
return [ map { $func->(dclone($_)) } @$statuses ]; |
|
27
|
|
|
|
|
1925
|
|
30
|
8
|
|
|
|
|
37
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub filter_grep { |
34
|
4
|
|
|
4
|
1
|
7012
|
my ($func) = @_; |
35
|
4
|
50
|
|
|
|
13
|
croak "func parameter is mandatory" if not defined $func; |
36
|
4
|
50
|
|
|
|
12
|
croak "func parameter must be a code-ref" if ref($func) ne "CODE"; |
37
|
|
|
|
|
|
|
return sub { |
38
|
4
|
|
|
4
|
|
15
|
my ($statuses) = @_; |
39
|
4
|
|
|
|
|
8
|
return [ grep { $func->($_) } @$statuses ]; |
|
16
|
|
|
|
|
70
|
|
40
|
4
|
|
|
|
|
25
|
}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |