disable auto-instantiation or warn about it
Matt Lawrence
matt.lawrence at virgin.net
Fri Jul 13 16:44:47 BST 2007
Jonathan Stowe wrote:
> On Fri, 2007-07-13 at 15:54 +0100, Frank v Waveren wrote:
>
>
>> that's been bothering me for some time:
>>
>> 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.
>
Really?
$ perl -Mstrict -we 'my $foo; $foo->{bar} = "baz"; print "$foo->{bar}\n"'
baz
Matt
More information about the london.pm
mailing list