in reply to Having an Issue updating hash of hashes
And if I may add see this also perldscuse warnings; use strict; use Data::Dumper; my %person; my $key; while (<DATA>) { for ( split /\s+/, $_ ) { if (/^(ID)=(.)/) { $key = $2; $person{$key} = { lc $1 => $2 }; } else { my ( $new_key, $value ) = split /=/, $_; $person{$key}{ lc $new_key } = $value; } } } print Dumper \%person; __DATA__ ID=1 First=John Last=Doe AGE=42 ID=2 First=Jane Last=Doe AGE=35 ID=3 First=Jack Last=Doe AGE=17 ID=4 First=Jill Last=Doe AGE=15
$key = $1 if /^ID=(.)/; my ( $new_key, $value ) = split /=/, $_; $person{$key}{ lc $new_key } = $value;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Having an Issue updating hash of hashes
by AppleFritter (Vicar) on Jul 05, 2014 at 18:42 UTC | |
by 2teez (Vicar) on Jul 05, 2014 at 18:54 UTC |