line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::replace_all; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
104778
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
15
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
8
|
2
|
|
|
2
|
|
8275
|
use Catmandu::Util::Path qw(as_path); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
132
|
|
9
|
2
|
|
|
2
|
|
1400
|
use Catmandu::Util::Regex qw(substituter); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
108
|
|
10
|
2
|
|
|
2
|
|
13
|
use namespace::clean; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
14
|
|
11
|
2
|
|
|
2
|
|
1069
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has search => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has replace => (fix_arg => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_fixer { |
20
|
3
|
|
|
3
|
|
38
|
my ($self) = @_; |
21
|
3
|
|
|
|
|
20
|
as_path($self->path) |
22
|
|
|
|
|
|
|
->updater(if_value => substituter($self->search, $self->replace)); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Catmandu::Fix::replace_all - search and replace using regex expressions |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Extract a substring out of the value of a field |
38
|
|
|
|
|
|
|
# {author => "tom jones"} |
39
|
|
|
|
|
|
|
replace_all(author, '([^ ]+) ([^ ]+)', '$2, $1') |
40
|
|
|
|
|
|
|
# {author => "jones, tom"} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SEE ALSO |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L<Catmandu::Fix> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |