thpfft spoke:
this is a little garbled...
hehehe, you've peered through the looking-glass of my mind.

a hash of hashrefs each of which refers to a { destination => count } pair. which is easily built:
my %totals; while (<LOGFILE>) { $totals{$1}->{$2}++ if m/(...)(...)(...)/; }
This gives me an idea, but I'm not sure if I am seeing it correctly. $totals{$1} gets the first memory match from the regexp, and ->{$2} get's the second, then ->{$2} get's incremented, right?

hum, Maybe another example...
The values that I am concered with from my regexp look like:
(the destination IP address will change BTW)
SRC=192.168.0.10, DST=66.39.54.27

I then log the source IP, the destination IP, and how many accesses per destination. My output should hopefully be something like:

192.168.0.10 accessed 66.39.54.27 49 times.

...and in case i've completely missed the point, the main trouble you're probably having...
Not at all, I think you got it spot-on! I have been fooling around with that %ips hash quite a bit, and you've validated my thoughts that it's not going to work like that.

Which suggests that you haven't quite grasped how perl's hashes work
It's that obvious, huh? ;) I'm trying to use hashes more and more every day for this exact reason.

...Some time with perldata, perldsc and perllol will help...
I will definately start reading some over there, thanks.

...along with a bit of strictness
Yup, I do that, and with warnings too! I firmly understand the advantage of having Perl tell me "don't do that!" =) The bit of code I posted is just the 'counting' sub of a larger beast.

...and if possible the perl cookbook.
I got it.

Thanks for taking time to respond to my garbled posting. When I get stuck on something, I have a hard time explaining the issue, but if I could explain it I probably wouldn't be so stuck, if you know what I mean.

In reply to Re: Re: Counting Occurences, (hash referencing another hash) by penguinfuz
in thread Counting Occurences, (hash referencing another hash) by penguinfuz

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.