Problems? Is your data what you think it is? | |
PerlMonks |
"print" of nonexistent element is actually altering a hashby larrymenard (Novice) |
on Feb 17, 2020 at 18:11 UTC ( [id://11113064]=perlquestion: print w/replies, xml ) | Need Help?? |
larrymenard has asked for the wisdom of the Perl Monks concerning the following question:
Monks, your responses to others have been very helpful to me for many years. Now however it is time to post my own question.
I am creating a multi-dimensional hash and then printing a non-existent key in that hash. Curiously (at least to me), that "print" is actually altering the hash, adding an invalid (for lack of a better word) key. The result is:
The "print" statement is the only thing that can possibly be altering the hash. Indeed, comment it out and the 2nd dump is normal. I have reproduced this on multiple versions of perl 5, up to and including 5.26.3 (on CentOS 8). Why is the "print" statement altering the hash? Any explanation (or even better, advice on how to avoid it) would be much appreciated. Thanks in advance.
Back to
Seekers of Perl Wisdom
|
|