I'd say you're on the right track. As long as you apply the regex to tear the 'MONKEY' part out of column 3 before you check to see if you've seen it before, you should do just fine.

I would make one pass through each line to build a hash with the value from column 3 as the key pointing to a hashref with num_false (a count) and col1_vals (an arrayref). Then I would go through each key of that hash and run the calculations you want to run. I'm thinking something like this (assuming your lines are in @lines):

my %seen = (); foreach my $line (@lines) { my @values = split ',', $line; my $col1_val = $values[0]; my $key = $values[2]; my $true_or_false = $values[7]; $key =~ /^LOGGED IN (\w+) GET/; $key = $1; $seen{$key}->{num_false}++ if $true_or_false eq 'false'; push @{$seen{$key}->{col1_vals}}, $col1_val; } foreach my $key (keys %seen) { my $calcd = calculate_stuff($seen{$key}->{col1_vals}); my $num_false = $seen{$key}->{num_false}; print <<HERE; Key: $key Calc'd values: $calcd Num false: $num_false HERE }

I just took a stab at guessing the proper regex (for example: are spaces allowed?) because I don't know what all your input looks like, but the basic idea holds.


In reply to Re: Hashes, Arrays, and Confusion -- In a bit over my head! by Riales
in thread Hashes, Arrays, and Confusion -- In a bit over my head! by bpthatsme

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.