line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::set_field; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
1786180
|
use Catmandu::Sane; |
|
19
|
|
|
|
|
1352
|
|
|
19
|
|
|
|
|
1392
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
177
|
use Moo; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
2817
|
|
8
|
19
|
|
|
19
|
|
17453
|
use Catmandu::Util::Path qw(as_path); |
|
19
|
|
|
|
|
47
|
|
|
19
|
|
|
|
|
1067
|
|
9
|
19
|
|
|
19
|
|
138
|
use namespace::clean; |
|
19
|
|
|
|
|
41
|
|
|
19
|
|
|
|
|
80
|
|
10
|
19
|
|
|
19
|
|
12512
|
use Catmandu::Fix::Has; |
|
19
|
|
|
|
|
51
|
|
|
19
|
|
|
|
|
138
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has value => (fix_arg => 1, default => sub {undef}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_fixer { |
18
|
61
|
|
|
61
|
|
642
|
my ($self) = @_; |
19
|
61
|
|
|
|
|
283
|
as_path($self->path)->setter($self->value); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Catmandu::Fix::set_field - add or change the value of a HASH key or ARRAY index |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Contrary to C<add_field>, this will not create the intermediate structures |
35
|
|
|
|
|
|
|
if they are missing. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Change the value of 'foo' to 'bar 123' |
40
|
|
|
|
|
|
|
set_field(foo, 'bar 123') |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Change a deeply nested key |
43
|
|
|
|
|
|
|
set_field(my.deep.nested.key, hi) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# If the second argument is omitted the field has a null value |
46
|
|
|
|
|
|
|
add_field(foo) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L<Catmandu::Fix> |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |