in reply to Print values and keys from hash of hashes.

The following hash creation isn't doing what you think it is. It's creating a hash with a hash reference as its only key, and with no value (value is assigned as undef).

my %hash = { 'debt-1' => { 'debt_id' => 10, 'mobile' => 11, 'address1' => 12 }, 'dedt-2' => { 'debt_id' => 20, 'mobile' => 21, 'address1' => 22 }, };

Instead of using braces (ie. {}) to create the hash which is used to create a hash reference to an anonymous hash, you need to use parens instead:

my %hash = ( 'debt-1' => { 'debt_id' => 10, 'mobile' => 11, 'address1' => 12 }, 'dedt-2' => { 'debt_id' => 20, 'mobile' => 21, 'address1' => 22 }, );

Things should begin to fall into place after you've fixed that.

Replies are listed 'Best First'.
Re^2: Print values and keys from hash of hashes.
by gurung (Sexton) on Feb 07, 2020 at 00:22 UTC
    Like stevo said, it is also mentioned in perlreftut (Make rule 2)
    If you write just "[]", you get a new, empty anonymous array. If you write just "{}", you get a new, empty anonymous hash. my %hash = ( 'debt-1' => { 'debt_id' => 10, 'mobile' => 11, 'address1' => 12 }, ); my $hash_ref = { 'debt-1' => { 'debt_id' => 10, 'mobile' => 11, 'address1' => 12 }, };