I have Perl code similar to the following:
# -- start --
my $res;
# run query to fetch IPv6 resources
while( my $row = $org_ip6_res->fetchrow_arrayref )
{
if( $row->[4] =~ /PA/ ) {
$res->{ipv6}{pa}{$row->[2]}++;
} elsif( $row->[4] eq 'PI' ) {
$res->{ipv6}{pi}{$row->[2]}++;
}
}
# -- stop --
At no point is $res
ever set prior to iterating over the query results yet the code runs just fine.
When I put print statements before each value I get blanks in both cases but if the print statements come after the increment has been applied I get a value of >= 1 depending on how many IPv6 resources the organization has.
My question is, do I take this to mean an uninitialized hash key in Perl automatically has a value of zero?
Sorry if it comes across as a newbie question but I'm just not familiar with such a construct
i.e. $hashref->{foo}->{bar}++
where a value has yet to be explicitly assigned to $hashref->{foo}->{bar}
. Thanks in advance!