disable auto-instantiation or warn about it

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Fri Jul 13 16:36:02 BST 2007

On Fri, 2007-07-13 at 16:13 +0100, Jonathan Stowe wrote:
> On Fri, 2007-07-13 at 15:54 +0100, Frank v Waveren wrote:
> > Is there any way to turn off auto-instantiation, or at least to make
> > perl emit a warning when it happens?
> > 
> > The auto-instantiation I mean here is the kind that makes evaluating
> > "$foo->{bar}" turn $foo into a hashref if it's undef. It's a nice
> > feature in some cases, but especially in larger projects it's a huge
> > source of bugs, in my experience. 
> It's generally called auto-vivification. However you want to "use
> strict" that will stop that particular class of bug.


$ perl -Mstrict -Mwarnings -le 'my $foo; my $bar = $foo->{bar}; print $foo'


More information about the london.pm mailing list