estreb has asked for the wisdom of the Perl Monks concerning the following question:
This gives the output:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array1 = ( "hello", "world" ); my @array2 = ( "here" ); my @array3 = ( "there" ); my %inner_hash = ( innerkey1 => \@array1, innerkey2 => \@array2, innerkey3 => \@array3 ); my %hash_of_hash_of_arrays = ( key => \%inner_hash ); print Dumper(\%hash_of_hash_of_arrays); exit(0);
Is there any way I can get this same output by defining only one variable? Something like:$VAR1 = { 'key' => { 'innerkey2' => [ 'here' ], 'innerkey3' => [ 'there' ], 'innerkey1' => [ 'hello', 'world' ] } };
...but that gives an error about "Reference found where even-sized list expected", and the output looks like:my %hash_of_hash_of_arrays = { 'key' => { 'innerkey2' => [ 'here' ], 'innerkey3' => [ 'there' ], 'innerkey1' => [ 'hello', 'world' ] } };
which obviously is not what I want at all. Please help.$VAR1 = { 'HASH(0x57e1d78)' => undef };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a hash of hashes of arrays
by toolic (Bishop) on Dec 15, 2014 at 16:57 UTC | |
|
Re: Creating a hash of hashes of arrays
by Athanasius (Cardinal) on Dec 15, 2014 at 17:13 UTC | |
by Anonymous Monk on Dec 15, 2014 at 18:05 UTC | |
|
Re: Creating a hash of hashes of arrays
by AnomalousMonk (Archbishop) on Dec 15, 2014 at 18:36 UTC | |
|
Re: Creating a hash of hashes of arrays
by estreb (Novice) on Dec 15, 2014 at 19:14 UTC |