I'm cross posting from beginners mailing list

Basically I want to see most active events in logs.

Technically, I don't even want a static average - if a group is 5,6,7, I'd like to see it the same as 8,10,12,14,16 but probably have the later rank higher based on $distance/$numbers. As it is, I can't even get this to work, so...

use strict; use warnings; use Data::Dumper; my $arr = [ 10, 7, 5, 10, 50, 70, 75, 72, 79, 80 ]; my $avg; foreach my $i ($#$arr) { $avg = ($i + ($avg ? $avg : $i)) / 2; } print "avg [$avg]\n"; @$arr = sort {$a <=> $b} @$arr; my $store; foreach my $i (0 .. $#$arr) { $store->[$i]{num} = $arr->[$i]; $store->[$i]{thresh} = $avg; foreach my $store_i (0 .. $#$store) { if (abs($arr->[$i] - $store->[$store_i]{num}) <= $store->[$i]{ +thresh}) { push @{$store->[$i]{group}}, $arr->[$i]; } } } print Dumper($store);

In reply to grouping numbers by ag4ve

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.