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.
In reply to Re: Initialization of hash element....
by blazar
in thread Initialization of hash element....
by Chon-Ji
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |