Hi

I do not know if this will help and also don't know if this will be faster, but I would try to use a different data structure: a hash of arrays with each array containing 3 elements: the interval lower limit, the interval upper limit and the tag count.

As a (very light) proof of concept, I will simplify the problem by simply forgetting about the a, b et so on, but just using a simple list of ranges. Or, if you prefer, I will deal only with your data related to letter a. Since I do not understand what your tags are about, I will just add 1 to the count when the value of the variable falls within the range.

This gives me the following session under the Perl debugger:

DB<49> @c = ([12,15], [12,17], [13,14], [14,19]) DB<50> x @c 0 ARRAY(0x20498b98) 0 12 1 15 1 ARRAY(0x20499588) 0 12 1 17 2 ARRAY(0x2049c428) 0 13 1 14 3 ARRAY(0x2049c488) 0 14 1 19 DB<51> $e = 17 DB<52> $_->[2]++ foreach grep {$e <= $_->[1]} grep {$e >= $_->[0]} @ +c DB<53> x @c 0 ARRAY(0x20498b98) 0 12 1 15 1 ARRAY(0x20499588) 0 12 1 17 2 1 2 ARRAY(0x2049c428) 0 13 1 14 3 ARRAY(0x2049c488) 0 14 1 19 2 1 DB<54> $e = 13; DB<55> $_->[2]++ foreach grep {$e <= $_->[1]} grep {$e >= $_->[0]} @ +c DB<56> x @c 0 ARRAY(0x20498b98) 0 12 1 15 2 1 1 ARRAY(0x20499588) 0 12 1 17 2 2 2 ARRAY(0x2049c428) 0 13 1 14 2 1 3 ARRAY(0x2049c488) 0 14 1 19 2 1 DB<57>

In reply to Re: Counter - number of tags per interval by Laurent_R
in thread Counter - number of tags per interval by baxy77bax

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.