knoppix@Microknoppix:~$ perl -Mstrict -MData::Dumper -wE '
> my %h = (
> ( 1 => q{j}, 2 => q{b} ),
> ( 1 => q{p}, 2 => q{b} ),
> );
> print Data::Dumper->Dumpxs( [ \ %h ], [ qw{ *h } ] );'
%h = (
'1' => 'p',
'2' => 'b'
);
knoppix@Microknoppix:~$
It is not clear from the three attempts what the OP desires. If a HoH is the aim then there should be a key with a value of the inner hash reference.
knoppix@Microknoppix:~$ perl -Mstrict -MData::Dumper -wE '
> my %h = (
> k1 => { 1 => q{j}, 2 => q{b} },
> k2 => { 1 => q{p}, 2 => q{b} },
> );
> print Data::Dumper->Dumpxs( [ \ %h ], [ qw{ *h } ] );'
%h = (
'k2' => {
'1' => 'p',
'2' => 'b'
},
'k1' => {
'1' => 'j',
'2' => 'b'
}
);
knoppix@Microknoppix:~$
An AoH fits the OP's data best perhaps?
knoppix@Microknoppix:~$ perl -Mstrict -MData::Dumper -wE '
> my @a = (
> { 1 => q{j}, 2 => q{b} },
> { 1 => q{p}, 2 => q{b} },
> );
> print Data::Dumper->Dumpxs( [ \ @a ], [ qw{ *a } ] );'
@a = (
{
'1' => 'j',
'2' => 'b'
},
{
'1' => 'p',
'2' => 'b'
}
);
knoppix@Microknoppix:~$
It would be useful if the OP could clarify their requirement.
|