Autovivitation makes
$counts{build}{$state} = 0;
behave like
( $counts{build} //= {} )->{$state} = 0;
For readability, make two lines
$counts{build}
$counts{build}{$state} = 0;
But, as you said, we need a common hash.
$counts{build}
$counts{build}{$state} = 0;
You can add the following to make sure that you do not accidentally vibrate the lone variable:
no autovivification qw( fetch store exists delete );
source
share