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...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
Update
Sorry, I missed that you wanted to break up dates... for that add
after the @nr{@keys} = @fields; line... that will put them in an array so $big_ash{13}{Dates}[0] will give you AM0$nr{Dates} = [split ',', $nr{Dates};
- 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |