in reply to Perl autovivifyies object property when using exists
Because of autovivification, $x->{ foo } means ( $x //= { } )->{ foo }.[1]
As such,
$fs4->{_structure}{'/Users/dotfiles/perl5/my_modules'}{BLAH}{Crap}
means
( ( ( ( $fs4 //= { } )->{_structure} //= { } )->{ '/Users/dotfiles/perl5/my_modules' } //= { } )->{ BLAH } //= { } )->{ Crap }
It has nothing to do with exists. (Notice how ->{ Crap } is not created.)
To avoid this, you could use a whole bunch of checks, or you could use the awesome autovivification pragma module.
no autovivification;
|
|---|