Hello, I'm working with an Excel sheet that's loaded into an array. I'm trying to remove duplicate rows from the array, based off matches on a specific field within that row. In this example, what I'd refer to as column 3, which is an account number.

Please forgive me, I am a novice at best. I've read a number of posts with some examples, but I'm not following the code because it doesn't seem to look at any specific value. A frequent example of the code suggested is:

@rows = do { my %seen; grep { !$seen{$_}++ } @rows };

I don't explicitly understand what's happening in that line, most importantly what it is matching to find a duplicate, but more importantly, it doesn't seem to work on my data.

If anyone has any suggestions, I would like to hear them. I'd also like to understand what the code is doing, rather than just cutting and pasting something. I want to learn, if possible.


In reply to Removing duplicates in multi-dimensional arrays by DamnitAddie

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.