in reply to Perl Hash Behavior.

> efficient way to check if a value exists in a hash, and if not, assign 0

golfing

DB<105> %h=(); print $h{key} //= 0; 0 DB<106> \%h => { key => 0 }

Update: beware that like this values like undef are not allowed!

Otherwise better use exists

Cheers Rolf

( addicted to the Perl Programming Language)