tetryl@tokyoprogrammer.com wrote: > > I love my variable and am looking for various ways of using it. > I will show you a bit of code. > > $ perl -e 'my $x;$x->{foo}' # OK > $ perl -e '(my $x)->{foo}' # NG > > I expected that autovivification would be applied to the > variable in the later case as well as in the first case, but > the results were different. If you look at what contexts permit and forbid autovivification, you'll see that the situation in perl is currently complex and probably not very consistent. Anyway, in general lvalue contexts don't permit it; a lexical declaration can be seen as this; and you still can write, in a rather obfuscated way, (my $x = {}) -> {foo} Your patch looks correct at a first glance, but I'm not very inclined to apply it, unless the crowd comes up with good reasons why to.Thread Previous | Thread Next