Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Your code does not even compile. Moreover, the logic with @list is wrong: you should keep all the information in the hash, not just the count. Like this:
#!/usr/bin/perl use warnings; use strict; my %error_count; while (<DATA>) { if (my ($error) = m/\](.*)\(20/) { $error_count{$error}{count}++; $error_count{$1}{list} //= [split /\s+/]; # Only remembers th +e first time. } } for (keys %error_count) { my @list = @{ $error_count{$_}{list} }; print "DEVICE\t--> $list[3]\n"; print "DATE\t--> $list[0] $list[1]\n"; print "TIME\t--> $list[2]\n"; print "ERROR\t--> $_\n"; print "\nThe above error occurred $error_count{$_}{count} times\n" +; } __DATA__ Oct 17 10:35:39 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:39) Oct 17 10:35:40 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:40) Oct 17 10:35:41 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:41) Oct 17 10:35:42 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:42) Oct 17 10:35:43 esw001tff2 [Root]Server reset. Occurred 1 time. (2012 +17 10:35:43) Oct 17 10:35:44 esw001tff2 [Root]Server reset. Occurred 1 time. (2012 +17 10:35:44) Oct 17 10:35:45 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:45) Oct 17 10:35:46 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:46) Oct 17 10:35:47 esw001tff2 [Root]Root login failure! Occurred 1 time. +(2012 17 10:35:47) Oct 17 10:35:48 esw001tff2 [Root]Root login failure! Occurred 1 time. +(2012 17 10:35:48) Oct 17 10:35:49 esw001tff2 [Root]Root login failure! Occurred 1 time. +(2012 17 10:35:49) Oct 17 10:35:50 esw001tff2 [Root]IP Spoofing from 255.255.255.255 to 2 +55.255.255.255! Occurred 1 time. (2012 17 10:35:50)
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

In reply to Re: Counting keys in a hash by choroba
in thread Counting keys in a hash by cspctec

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (4)
    As of 2014-09-21 01:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (165 votes), past polls