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 };
In reply to Creating a hash of hashes of arrays by estreb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |