in reply to References for subroutines to Hashes in Hashes :)
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: References for subroutines to Hashes in Hashes :)
by merlijn_u (Novice) on Aug 17, 2001 at 18:03 UTC | |
by suaveant (Parson) on Aug 17, 2001 at 18:17 UTC | |
by merlijn_u (Novice) on Aug 17, 2001 at 20:28 UTC | |
by merlijn_u (Novice) on Aug 17, 2001 at 18:43 UTC | |
by suaveant (Parson) on Aug 17, 2001 at 18:57 UTC | |
by merlijn_u (Novice) on Aug 17, 2001 at 18:45 UTC | |
by merlijn_u (Novice) on Aug 17, 2001 at 19:15 UTC | |
by suaveant (Parson) on Aug 17, 2001 at 19:58 UTC |