Your question is somewhat non-sensical because you dont set hash kets, really, you set values, but I'm going to interpret this question as meaning "How can I have hash values automatically initialized as zero rather than undef?"
A cursory reading of
Tie::Memoize reveals that it looks like what you might want.