I'm trying to only print the occurrence once

Not sure what you are trying to do. If you want to stop multiple records then just use a %seen{key} hash e.g.

#!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||
poj

In reply to Re^3: Print Max Hash by poj
in thread Print Max Hash by bartrad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.