in reply to undefined value as an ARRAY reference sometimes ok

See: What does Autovivify mean?

Calling $list->[0] causes $list to autovivify. You can see this happening here:

#!perl use strict; my $list = undef; print ref $list, "\n"; # should print only a blank line my $item = $list->[0]; print ref $list, "\n"; # should print ARRAY

Replies are listed 'Best First'.
Re^2: undefined value as an ARRAY reference sometimes ok
by Anonymous Monk on Dec 13, 2011 at 23:52 UTC
    Maybe I missed it, but the refs you gave didn't explain why this didn't autovivify:
    my $item = get_no_list()->[0]; #no way

      Sorry for the lack of clarity in my first response. It's the attempt to dereference $list that causes the autovivification. In your last example, you are attempting to dereference your function call, not $list.