in reply to Hash arrays
Something like this?:
Output:use warnings; use strict; use Data::Dumper; my %family_hash; while (<DATA>) { my ( $key, @values ) = split /\s/, $_; push @{ $family_hash{$key} }, @values; } print Dumper \%family_hash; __DATA__ father male 65 Engineer mother female 60 home_engineering son male 28 musician daughter female 19 software_engineer
You should see perldsc, HASHES-OF-ARRAYS$VAR1 = { 'son' => [ 'male', '28', 'musician' ], 'daughter' => [ 'female', '19', 'software_engineer' ], 'father' => [ 'male', '65', 'Engineer' ], 'mother' => [ 'female', '60', 'home_engineering' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash arrays
by BillKSmith (Monsignor) on Dec 26, 2012 at 14:50 UTC | |
by NetWallah (Canon) on Dec 26, 2012 at 16:30 UTC |