Here is some code that does what you want... I think...
my %big_ash; my @keys; while(<DATA>) { my @fields = split /--+/, $_; next unless @fields; if($. == 1) { #first line @keys = @fields; next; } my %nr; @nr{@keys} = @fields; $big_ash{$nr{NR}} = \%nr; } print "$big_ash{14}{Dates}\n"; __DATA__ NR------E-mail----------Comment---------Dates-------------Age--Action_ +date 12------Tom@info.com----blablabla-------AM0,PM0,AM1,PM1---32---10-10-2 +001 13------Frank@info.com--blablabla-------AM0,PM0-----------45---10-10-2 +001 14------Sand@info.com---blablabla-------AM1,PM1,PM2-------47---10-10-2 +001 14------Sand@info.com---blablabla-------AM1,PM1,PM2-------47---12-10-2 +001
this assumes you always have at least -- as a record separator... you may want to use spaces to pad your data and look into unpack to get your data back... or change your delimiter to something like | that you don't have in any of your data...
Since a hash within a hash is stored as a reference, you do not need the \$analyst_record{$c->{ANA_ID} ... $analyst_record{$c->{ANA_ID} itself will return a ref.

Update
Sorry, I missed that you wanted to break up dates... for that add

$nr{Dates} = [split ',', $nr{Dates};
after the @nr{@keys} = @fields; line... that will put them in an array so $big_ash{13}{Dates}[0] will give you AM0
Also... using NR as a key won't work right if you have the same NR twice... which you seem to have, but is the exact same line...

                - Ant
                - Some of my best work - Fish Dinner


In reply to Re: References for subroutines to Hashes in Hashes :) by suaveant
in thread References for subroutines to Hashes in Hashes :) by merlijn_u

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.