in reply to Re^3: Having an Issue updating hash of hashes
in thread Having an Issue updating hash of hashes
#!/usr/bin/perl use Data::Dumper; use strict; use warnings; getPeople(); sub getPeople { my $file = 'list.txt'; my $people; open( LIST, "< $file" ) or die "Can't open $file : $!"; while (my $row = <LIST> ) { my ($id, $first, $last, $age) = (split /[\s=]/, $row)[ +1, 3, 5, 7]; $people -> { $id } = { id => $id, first => $first, last => $last, age => $age }; } print Dumper($people); print "The person with ID 3 is $people->{3}{first} $people->{3}{last}\ +n"; close LIST; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Having an Issue updating hash of hashes
by Laurent_R (Canon) on Jul 06, 2014 at 20:44 UTC |