[tpm] dereferencing anonymous hashes

Fulko Hew fulko.hew at gmail.com
Tue Apr 10 11:05:35 PDT 2007


I always seem to have a problem dereferencing anonymous hashes...
(a mental block, or I'm just mental!)

In a subroutine I create the thing as such:

sub foo {
  my $device = {};                           # create an anonymous hash
  $config{$cfg}{device} = \$device;    # And stick it into the major
data structure

$device{$devId}{status) = 'ok';         # and populate the anonymous hash
$device{$devId}{msgCnt}++;
}

Then later on I want to extract the status:

my %device = ${$config{$cfg}{device}};
$status = $device{$devId}{status};

but this isn't quite right.  ;-(


More information about the toronto-pm mailing list