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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |