in reply to Perl Hash Behavior.

if (!defined $hash{$key}) { $hash{$key} = 0; }

Or that new-fangled thing with the //.