[tpm] dereferencing anonymous hashes
adam.prime at utoronto.ca
adam.prime at utoronto.ca
Tue Apr 10 11:19:23 PDT 2007
Do you really want a reference to a reference to a hash here?
$config{$cfg}{device} = \$device;
That looks like the root of the problem to me. should be:
$config{$cfg}{device} = $device;
to work with the rest of your code i'd think, not having tested anything.
Adam
Quoting Fulko Hew <fulko.hew at gmail.com>:
> 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. ;-(
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
More information about the toronto-pm
mailing list