Ppeoc has asked for the wisdom of the Perl Monks concerning the following question:
Only the key Daughter gets initialized to 1. Please correct my error. I am looking for a hash like thisuse strict; use warnings; use Data::Dumper; my $name = "Father" ; my @terms = qw(Mom Wife Son Daughter); my %fam_old = map{ $name => { $_,1 }} @terms; print Dumper \%fam_old,"\n";
$VAR1 = { "Father" => { 'Son' => 1, 'Daughter' => 1, 'Wife' => 1, 'Mom' => 1 }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Initializing hashes of hashes
by GrandFather (Saint) on Dec 19, 2015 at 21:48 UTC | |
|
Re: Initializing hashes of hashes
by Discipulus (Canon) on Dec 19, 2015 at 21:52 UTC | |
|
Re: updated question: Initializing hashes of hashes
by BillKSmith (Monsignor) on Dec 20, 2015 at 04:20 UTC | |
|
Re: Initializing hashes of hashes
by Anonymous Monk on Dec 19, 2015 at 22:43 UTC |