| 1 | # | ||||||||||
| 2 | # $Id: Uniq.pm,v 58d7ce835577 2023/03/25 10:34:10 gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package OPP::Proc::Uniq; | ||||||||||
| 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 | # | uniq hostname | ||||||||||
| 15 | # | uniq ip,port,forward | ||||||||||
| 16 | # | ||||||||||
| 17 | sub process { | ||||||||||
| 18 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
process: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||
| 19 | 0 | my ($input) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 0 | my $fields = $self->options->{0}; # XXX: check argument | |||||||||
| 22 | 0 | ▶ | return unless defined($fields); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 0 | my @fields = split('\s*,\s*', $fields); | |||||||||
| 25 | |||||||||||
| 26 | 0 | my $k = ''; | |||||||||
| 27 | 0 | for my $this (@fields) { | |||||||||
| 28 | 0 | my $values = $self->value($input, $this); | |||||||||
| 29 | 0 | ▶ | next unless defined($values); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | for my $v (@$values) { | |||||||||
| 31 | 0 | $k .= $this.'-'.$v.':'; | |||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | # Skip when no key found: | ||||||||||
| 36 | 0 | ▶ | return 1 unless length $k; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | unless ($self->state->exists($k, $self->idx)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | my $clone = $self->clone($input); | |||||||||
| 40 | 0 | my %fields = map { $_ => 1 } @fields; | |||||||||
| 41 | 0 | for my $this (@{$self->fields($clone)}) { | |||||||||
| 42 | 0 | ▶ | next if $fields{$this}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->delete($clone, $this); | |||||||||
| 44 | } | ||||||||||
| 45 | 0 | $self->output->add($clone); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | $self->state->incr($k, $self->idx); | |||||||||
| 49 | |||||||||||
| 50 | 0 | return 1; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 1 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||