I have a HoH reference like this:
I am trying to turn this HoH inside out. i.e., I am trying to get:$VAR1 = { 'FOO' => { 'TABLE_NAME' => 'FOO', 'TABLE_TYPE' => 'REFERENCE' }, 'BAR' => { 'TABLE_NAME' => 'BAR', 'TABLE_TYPE' => 'REFERENCE' }, 'BAZ' => { 'TABLE_NAME' => 'BAZ', 'TABLE_TYPE' => 'CUSTOMER' } };
The easiest option I can think of at this point is to create a HoA from the reference to the HoH. Something like:$VAR1 = { 'REFERENCE' => [ 'FOO', 'BAR' ], 'CUSTOMER' => 'BAZ' };
But this gives me the following error:my %HoA; foreach my $key (keys %$ref_to_HoH){ my $type = $ref_to_HoH->{$key}->{TABLE_TYPE}; if (exists $HoA{$type}){ push @{$HoA{$type}},$key; }else { $HoA{$type} = $key; } }
Can't use string ("FOO") as an ARRAY ref while "strict refs" in use at + .....
What am I doing wrong here? Greatly appreciate any help from the revered monks here.
Thanks,
In reply to error creating hash of array by HarshaHegde
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |