[VPM] question about possible Perl runtime bug

Darren Duncan darren at DarrenDuncan.net
Sun Jul 6 22:11:35 CDT 2003


nathaneal said:
> >is it so-called "proper behaviour"?
>
>I *think* that what you have encountered is called autovivification, and
>depending how you look at it, it's Perl being naughty or nice.  There was a
>thread on this on perlmonks last week, some moron was complaining that he was
>mis-spelling his keys or even hash names and loading up the wrong hashes with
>the wrong values, and he wanted a 'no autovivification' sort of pragma.  I
>told him to stop whining and pay more attention while programming. :)
>
>Gosh, hope it wasn't any of you...

No, that wasn't me.  I've never used or read Perl Monks before, although I have heard that they exist. 

That said, I came up with my question here while trying to debug a method I wrote (the bug was that I didn't pass a hash reference as an argument when I should have). 

When I discovered the problem, I figured that this was something Perl should be checking for.  Just as we have "use strict" to turn off auto-variable-instantiation, we should have something to disable auto-vivification.

If I pass a scalar and try to use it as a hash ref, Perl has a runtime error, but it isn't with an undefined value; I would expect the same behaviour when the variable contained anything but a hash ref.

I will look into this issue later, and if the functionality doesn't exist, I will suggest it to the relevant Perl core developers.

-- Darren Duncan



More information about the Victoria-pm mailing list