Skip to content

Commit 913a40f

Browse files
author
GomoR
committed
- new: addfield proc
1 parent 0e41813 commit 913a40f

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

lib/OPP/Proc/Addfield.pm

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#
2+
# $Id: Addfield.pm,v 3c62c12dda1e 2023/09/10 07:48:40 gomor $
3+
#
4+
package OPP::Proc::Addfield;
5+
use strict;
6+
use warnings;
7+
8+
use base qw(OPP::Proc);
9+
__PACKAGE__->cgBuildIndices;
10+
11+
our $VERSION = '1.00';
12+
13+
#
14+
# | addfield scope=target mytag=test
15+
#
16+
sub process {
17+
my $self = shift;
18+
my ($input) = @_;
19+
20+
my $options = $self->options;
21+
22+
my %fields = ();
23+
for my $k (keys %$options) {
24+
next if $k eq 'args';
25+
next unless defined($options->{$k});
26+
$fields{$k} = $options->{$k}[0] if defined($options->{$k}[0]);
27+
}
28+
29+
for my $k (keys %fields) {
30+
next unless defined($fields{$k});
31+
$input->{$k} = $fields{$k};
32+
}
33+
34+
$self->output->add($input);
35+
36+
return 1;
37+
}
38+
39+
1;
40+
41+
__END__
42+
43+
=head1 NAME
44+
45+
OPP::Proc::Addfield - addfiel processor
46+
47+
=head1 SYNOPSIS
48+
49+
=head1 DESCRIPTION
50+
51+
=head1 COPYRIGHT AND LICENSE
52+
53+
Copyright (c) 2023, Patrice E<lt>GomoRE<gt> Auffret
54+
55+
You may distribute this module under the terms of The BSD 3-Clause License.
56+
See LICENSE file in the source distribution archive.
57+
58+
=head1 AUTHOR
59+
60+
Patrice E<lt>GomoRE<gt> Auffret
61+
62+
=cut

0 commit comments

Comments
 (0)