in reply to hash of hashes and memory space...

Well, what's a variable to you?

Your question doesn't make that much sense. What's your real question?

Replies are listed 'Best First'.
Re^2: hash of hashes and memory space...
by bcarroll (Pilgrim) on Mar 23, 2010 at 19:02 UTC
    My question came about from looking at the output of a Data::Dumper and Data::Dump of a hash of hashes I am working with. Dumping the hash only prints the first hash key/value pairs not the under lining hashes or their key/value pairs. This made me think that a hash of hashes is not one single variable (container) but that each embedded hash is it's own separate container.
      A "hash of hash" is really a "hash of references to hashes".
      $h{foo}{bar} = 123;
      is short for
      $h{foo}->{bar} = 123;
      and
      ${ $h{foo} }{bar} = 123;

      Something to try:

      my %a; my %b; $a{foo} = \%b; $a{foo}{bar} = 123; print("$b{bar}\n");

      Strange. When I use Data::Dumper, I get all the subhashes shown too. Example:

      #!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash= ( 4, {3,4,5,6,7,8}); $hash{a}{b}{c}{d}{e}=366; print Dumper(\%hash); #output: $VAR1 = { '4' => { '3' => 4, '7' => 8, '5' => 6 }, 'a' => { 'b' => { 'c' => { 'd' => { 'e' => 366 } } } } };

      Maybe $Data::Dumper::Maxdepth is set to 1 in your script

        print Dumper(\%hash);

        You found my problem with Data::Dumper...

        I was using print Dumper(%hash);

        Thanks!