| 1 | # | ||||||||||||
| 2 | # $Id: Fields.pm,v 17cc8d9dc427 2023/03/07 06:24:43 gomor $ | ||||||||||||
| 3 | # | ||||||||||||
| 4 | package OPP::Proc::Fields; | ||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use base qw(OPP::Proc); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | __PACKAGE__->cgBuildIndices; | |||||||||||
| 10 | |||||||||||||
| 11 | 1 | our $VERSION = '1.00'; | |||||||||||
| 12 | |||||||||||||
| 13 | # | ||||||||||||
| 14 | # | fields ip,protocol,domain,app.http.component.product | ||||||||||||
| 15 | # | ||||||||||||
| 16 | sub process { | ||||||||||||
| 17 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
process: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||
| 18 | 0 | my ($input) = @_; | |||||||||||
| 19 | |||||||||||||
| 20 | 0 | ▶ | my $keep = $self->options->{0} || {}; | ||||||||||
|
Condition0%0/2
$self->options->{'0'} || {}
MC/DC0%0/1
$self->options->{'0'} || {}
$self->options->{'0'}
Truth table0%0/2
A
A= $self->options->{'0'}
| |||||||||||||
| 21 | |||||||||||||
| 22 | # Build list of fields to be kept from input argument: | ||||||||||||
| 23 | 0 | ▶ | if (defined($keep)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 0 | $keep = { map { $_ => 1 } split(/\s*,\s*/, $keep) }; | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | # Get list of full input field names: | ||||||||||||
| 28 | 0 | my $fields = $self->fields($input); | |||||||||||
| 29 | |||||||||||||
| 30 | # Iterate over all input fields and delete those not wanted for being kept: | ||||||||||||
| 31 | 0 | for my $k (@$fields) { | |||||||||||
| 32 | 0 | ▶ | $self->delete($input, $k) if !$keep->{$k}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 0 | ▶ | $self->output->add($input) if %$input > 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | |||||||||||||
| 37 | 0 | return 1; | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 1 | 1; | |||||||||||
| 41 | |||||||||||||
| 42 | __END__ | ||||||||||||