in reply to Initialization of hash element....

Because of this I thought that if a hash element has no value and it is used on an arithmetic operation then its default value is zero. Am I correct?

Yes, and this has not strictly to do with hash elements, but with any variable, be it a simple scalar or an element of an aggregate. One caveat though: under warnings, you will get a warning if you use such a value in a generic expression, but you won't if you use mutators instead:

tilde:~ [13:53:30]$ perl -we '$a=$a+1' Use of uninitialized value in addition (+) at -e line 1. tilde:~ [13:53:50]$ perl -we '$a+=1' Name "main::a" used only once: possible typo at -e line 1. tilde:~ [13:53:58]$ perl -we '$a++' Name "main::a" used only once: possible typo at -e line 1.

Replies are listed 'Best First'.
Re^2: Initialization of hash element....
by ysth (Canon) on Jun 01, 2007 at 18:30 UTC
    $ perl -we '$a*=0' Name "main::a" used only once: possible typo at -e line 1. Use of uninitialized value in multiplication (*) at -e line 1.
    Only certain mutators suppress the warning - those that most make sense with a 0 / "" default. These are:

    ++ and -- (either pre or post), +=, -=, .=, |=, ^=, &&=, ||=.

    But last I checked, some of those erroneously warn when used on a tied variable.