It is kind of difficult to figure out exactly what you are trying to do. As far as I can tell, you are trying to do something like the following. You end up with an awful lot of duplicated information though.

If you showed an example of what your expected data structure looked like, it would be easier to help you.

Update: I see anonymonk already had similar advice...

use warnings; use strict; use Data::Dumper; my @totlines = map {chomp; [split /,/, $_]} <DATA>; #print Dumper \@totlines; my %hash = ( '_W9C2JJDCB' => [ '_W9C2JJDCB', '201200240', 'TEST: IGNORE', 'John Doe', 'Closed', 'HIP', 'email@email.com', 'email2@email.com', ], '_W9C2JJDCA' => [ '_W9C2JJDCA', '201200245', 'TEST: IGNORE', 'Jane Doe', 'Closed', 'HOP', 'email@imail.com', 'email2@imail.com', ], ); for my $line (@totlines) { my $key = $line->[0]; if ( defined $hash{$key} ){ push @{$hash{$key}}, @$line; } } print Dumper \%hash; __DATA__ _W9C2JJDCA,<P>This is the problem1.</P>,<P>This is res1</P> _W9C2JJDCA,<P>This is the problem2.</P>,<P>This is res2</P> _W9C2JJDCA,<P>This is the problem3.</P>,<P>This is res3</P> _W9C2JJDCB,<P>This is the problem1.</P>,<P>This is res1</P> _W9C2JJDCB,<P>This is the problem2.</P>,<P>This is res2</P> _W9C2JJDCB,<P>This is the problem3.</P>,<P>This is res3</P> _W9C2JJDCC,<P>This is the problem1.</P>,<P>This is res1</P> _W9C2JJDCC,<P>This is the problem2.</P>,<P>This is res2</P> _W9C2JJDCC,<P>This is the problem3.</P>,<P>This is res3</P>

In reply to Re: Comparing Hash key with array by thundergnat
in thread Comparing Hash key with array by packetstormer

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.