in reply to Re^2: Print Max Hash
in thread Print Max Hash
Not sure what you are trying to do. If you want to stop multiple records then just use a %seen{key} hash e.g.
poj#!perl use strict; my %seen = (); while ( my $line = <DATA> ) { next if $line =~ /Insufficent|CLEARED/; if ( $line =~ /SNMP/ ) { my @f = split /\|/, $line; my $node_ip = $f[4] || 'N/A'; my $message = $f[13]; my (undef,$ne) = split /[ &]+/,$f[15]; unless ( $seen{$ne}++ ){ printf "%-15s | %9s | %s \n", $node_ip, $ne, $message; } } } __DATA__ 143599203|No|NACK|ENA||Major|20180129054027||ARM|NSA|PRM|0|DCN|Insuffi +cient SNMP security settings|HN408-CP-1E-I|3176 && 1234|||||||No|| 143599356|No|NACK|ENA|192.168.0.1|Major|20180129054037||CLR|NSA|PRM|0| +DCN|CLEARED: Network element does not respond to SNMP requests|HN4000 +e|3176 && 12345|||||||No|| 143599357|No|NACK|ENA|192.168.0.2|Major|20180129054039||CLR|NSA|PRM|0| +DCN|CLEARED: Insufficient SNMP security settings|HN4000e|3176 && 1234 +56|||||||No|| 143599999|No|NACK|ENA|192.168.0.3|Major|20180129054529||ARM|NSA|PRM|0| +DCN|Network element does not respond to SNMP requests|HN4000e|3176 && + 7890|||||||No|| 143599999|No|NACK|ENA|192.168.0.3|Major|20180129054529||ARM|NSA|PRM|0| +DCN|Network element does not respond to SNMP requests|HN4000e|3176 && + 7890|||||||No|| 143599999|No|NACK|ENA|192.168.0.3|Major|20180129054529||ARM|NSA|PRM|0| +DCN|Network element does not respond to SNMP requests|HN4000e|3176 && + 7890|||||||No||
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Print Max Hash
by bartrad (Beadle) on Jan 30, 2018 at 14:35 UTC | |
by poj (Abbot) on Jan 30, 2018 at 14:55 UTC | |
by johngg (Canon) on Jan 30, 2018 at 14:46 UTC |