Hi,

You haven't told us what the problem is, but the code you posted does not compile because you're using barewords like 887ww45 instead of quoted strings, so that would be the first thing to fix - replace the square brackets with quotes (i.e. [887ww45] becomes "887ww45") and your code will work. It's not particularly efficient though, mostly because of the grep. Please see the following links:

I wish I could to this without having to add the new values to a new variable.

While it's possible to solve this without a second data structure, it's a bit easier to code using more than one. Why would you want to avoid a second data structure, is your actual data very big?

Hope this helps,
-- Hauke D

Update: Added quote.


In reply to Re: Remove duplicated data from array ref by haukex
in thread Remove duplicated data from array ref by Maresia

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.