I am working on a little script that will check the value of field X and increment the value of field Y by 1 based on the number of times the value of X has come up. My first though was to simply create and array and push unique X values to it and Set Y to 1 when that happens...if it were not unique and equaled a value already in the array I would add 1 to Y. Simple enough....if only all instances of X were in consecutive, which they are not.

My question is how to accomplish this? I just can't seem to wrap my brain around it (even though it seems trivial). I am still very new to perl and sometimes the obvious just is not obvious to me =P


In reply to How to increment a sequence number for evert instance of a value? by aschroh

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.