I think you should be using $subnets{$ip}{'comment'} instead of $subnets{$ip}{$comment} unless the variable $comment contains the string 'comment'.
UPDATE: (before I had seen kennethk's post or he this update:) The whole thing can be expressed as (in newer versions of Perl):
$subnets{$_}{'comment'} //= 'ALLOCATED' for keys %subnets;
UPDATE 2: Comment from kennethk: code can also be written as
$_->{comment} //= 'ALLOCATED' for values %subnets;
In reply to Re: Check/set hash of hashes value
by hdb
in thread Check/set hash of hashes value
by stroke
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |