line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86779
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_array_ref); |
7
|
1
|
|
|
1
|
|
7
|
use Catmandu::Util::Regex qw(as_regex); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
381
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
9
|
1
|
|
|
1
|
|
371
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
10
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
331
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
651
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has search => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has invert => (fix_opt => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my ($self) = @_; |
20
|
|
|
|
|
|
|
my $regex = as_regex($self->search); |
21
|
4
|
|
|
4
|
|
31
|
my $cb = $self->invert |
22
|
4
|
|
|
|
|
15
|
? sub { |
23
|
|
|
|
|
|
|
[grep {!m/$regex/} @{$_[0]}]; |
24
|
|
|
|
|
|
|
} |
25
|
1
|
|
|
1
|
|
1
|
: sub { |
|
4
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
3
|
|
26
|
|
|
|
|
|
|
[grep {m/$regex/} @{$_[0]}]; |
27
|
|
|
|
|
|
|
}; |
28
|
3
|
|
|
3
|
|
5
|
as_path($self->path)->updater(if_array_ref => $cb); |
|
10
|
|
|
|
|
90
|
|
|
3
|
|
|
|
|
7
|
|
29
|
4
|
100
|
|
|
|
21
|
} |
30
|
4
|
|
|
|
|
28
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Catmandu::Fix::filter - Filter values out of an array based on a regular expression |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# words => ["Patrick","Nicolas","Paul","Frank"] |
43
|
|
|
|
|
|
|
filter(words,'Pa') |
44
|
|
|
|
|
|
|
# words => ["Patrick","Paul"] |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# filter only values that do NOT match the pattern: |
47
|
|
|
|
|
|
|
filter(words, 'Pa', invert: 1) |
48
|
|
|
|
|
|
|
# words => ["Nicolas","Frank"] |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L<Catmandu::Fix> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |