| 1 | package BusyBird::Filter; | ||||||||||
| 2 | 2 | ▶ | use v5.8.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Exporter 5.57 qw(import); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Storable qw(dclone); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | our @EXPORT_OK = qw(filter_map filter_each filter_grep); | |||||||||
| 10 | 2 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | sub filter_each { | ||||||||
|
Subroutine
filter_each: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 13 | 1 | my ($func) = @_; | |||||||||
| 14 | 1 | ▶ | croak "func parameter is mandatory" if not defined $func; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 1 | ▶ | croak "func parameter must be a code-ref" if ref($func) ne "CODE"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 1 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 17 | 1 | my $statuses = shift; | |||||||||
| 18 | 1 | $func->($_) foreach @$statuses; | |||||||||
| 19 | 1 | return $statuses; | |||||||||
| 20 | 1 | }; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 8 | ▶ | sub filter_map { | ||||||||
|
Subroutine
filter_map: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 24 | 8 | my ($func) = @_; | |||||||||
| 25 | 8 | ▶ | croak "func parameter is mandatory" if not defined $func; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 8 | ▶ | croak "func parameter must be a code-ref" if ref($func) ne "CODE"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 24 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 24 | my $statuses = shift; | |||||||||
| 29 | 24 | return [ map { $func->(dclone($_)) } @$statuses ]; | |||||||||
| 30 | 8 | }; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 4 | ▶ | sub filter_grep { | ||||||||
|
Subroutine
filter_grep: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 34 | 4 | my ($func) = @_; | |||||||||
| 35 | 4 | ▶ | croak "func parameter is mandatory" if not defined $func; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 4 | ▶ | croak "func parameter must be a code-ref" if ref($func) ne "CODE"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 4 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 4 | my ($statuses) = @_; | |||||||||
| 39 | 4 | return [ grep { $func->($_) } @$statuses ]; | |||||||||
| 40 | 4 | }; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | 2 | 1; | |||||||||
| 45 | __END__ | ||||||||||