Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Different Type of Hashes

by johngg (Canon)
on May 07, 2012 at 10:51 UTC ( [id://969239]=note: print w/replies, xml ) Need Help??


in reply to Re: Different Type of Hashes
in thread Different Type of Hashes

Neither, I think, is #2!

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.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://969239]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found