in reply to Having an Issue updating hash of hashes
I think that getting the individual values to be stored in the hashes could be made significantly simpler, but that's not what you asked for, I don't want to get off-topic at this point. If you're interested, other monks and myself can of course help you on that.sub getPeople { my ( $id, $first, $last, $age ); my $file = 'list.txt'; my @people; # using directly an array # my $cntr; -- now useless open( LIST, "< $file" ) or die "Can't open $file : $!"; while (my $row = <LIST> ) { # $cntr++; -- now no longer useful my ($id, $first, $last, $age ) = split( /\s/, $row ); $id = (split( /=/, $id ))[1]; $first = (split( /=/, $first ))[1]; $last = (split( /=/, $last ))[1]; $age = (split( /=/, $age ))[1]; push @people, { 'id' => "$id", 'first' => "$first", 'last' => "$last", 'age' => "$age" }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Having an Issue updating hash of hashes
by perlguyjoe (Novice) on Jul 05, 2014 at 17:48 UTC | |
by Laurent_R (Canon) on Jul 05, 2014 at 19:07 UTC | |
by AnomalousMonk (Archbishop) on Jul 06, 2014 at 00:24 UTC | |
by boftx (Deacon) on Jul 06, 2014 at 01:17 UTC | |
by Laurent_R (Canon) on Jul 06, 2014 at 08:11 UTC | |
by perlguyjoe (Novice) on Jul 06, 2014 at 19:48 UTC | |
by Laurent_R (Canon) on Jul 06, 2014 at 20:44 UTC | |
by AnomalousMonk (Archbishop) on Jul 06, 2014 at 00:07 UTC | |
by Laurent_R (Canon) on Jul 06, 2014 at 09:21 UTC |