We don't have access to your database and are not likely to mock up your web site to test out the code. It makes it much easier for us (and for your own testing) if you mock up just enough context to test the code you are having trouble with. The following may point you in the right direction:

use strict; use warnings; use strict; my @inColors = ( ['blue', 'foo'], ['red', 'bar'], ['blue', 'baz'], ); my %colors; for my $inColor (@inColors) { if (exists $colors{$inColor->[0]}) { print "Replacing $inColor->[0], $colors{$inColor->[0]} with $i +nColor->[1]\n"; } else { print "Adding $inColor->[0], $inColor->[1]\n"; } $colors{$inColor->[0]} = $inColor->[1]; }

Prints:

Adding blue, foo Adding red, bar Replacing blue, foo with baz

Perl's payment curve coincides with its learning curve.

In reply to Re: Hashes, Arrays, Comparing Values to Elements by GrandFather
in thread Hashes, Arrays, Comparing Values to Elements by Trihedralguy

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.