line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
92890
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_array_ref); |
7
|
1
|
|
|
1
|
|
7
|
use Catmandu::Util::Regex qw(as_regex); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
8
|
1
|
|
|
1
|
|
484
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
386
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
11
|
1
|
|
|
1
|
|
341
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
737
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
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
|
|
37
|
my $cb = $self->invert |
22
|
4
|
|
|
|
|
20
|
? sub { |
23
|
|
|
|
|
|
|
[grep {!m/$regex/} @{$_[0]}]; |
24
|
|
|
|
|
|
|
} |
25
|
1
|
|
|
1
|
|
2
|
: sub { |
|
4
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
3
|
|
26
|
|
|
|
|
|
|
[grep {m/$regex/} @{$_[0]}]; |
27
|
|
|
|
|
|
|
}; |
28
|
3
|
|
|
3
|
|
5
|
as_path($self->path)->updater(if_array_ref => $cb); |
|
10
|
|
|
|
|
84
|
|
|
3
|
|
|
|
|
8
|
|
29
|
4
|
100
|
|
|
|
23
|
} |
30
|
4
|
|
|
|
|
17
|
|
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 |