Perl - Autovivification

When I first heard that term, I was worried. I felt ashamed of myself for not knowing it. After all I've been writing Perl scripts for almost 3 years now. And I still don't know what that means.

But finally I came out of my complex. And I realized that computer science is too vast to know everything about everything. You learn it as you get through it. So apparently:
Autovivification is the name for what happens when you attempt to assign a nonexistant entry of a hash; Perl actually creates the missing hash entry for the key you specified. You might not have intended that to happen. But Perl does exactly that. I've recently seen a bug in my new team because of this very feature or curse of Perl. And it did take a long time for them figure out the root cause of the problem. Because Perl doesn't complain when this happens. This is more of a logical error than a compile time or run time error. Hence too hard to find.

So beware of this problem with Perl Hashes.
Keep that in mind.
Till I find a new term to share with you.

Comments