Thanks for the investigation!

Some additional observations:

no autovivification qw/store/; causes the offending part (of your minimal example) to die with "Can't vivify reference at -e line 1.".

Reading the autovivification module's documentation gave me a hint: lvalue context. Searching that led me to a Perlmonks article from 12 years ago: Autovivification of scalars in sub calls Those who don't know history are doomed to repeat it, apparently.

The key phrase seems to be "arguments to subs are lvalues" and apparently this is a feature. Still, I find it surprising and confusing.

The linked thread mentions that "incidentally, builtin functions do not provide a similar service" (i.e. autovivification for their arguments) - this is not unconditionally true:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $h={}; for my $x ("pop", "shift", "map {1}", "grep {1}", "chomp", "lc", "loca +ltime", "cos") { my $str = $x.q/ @{$h->{'/ . $x . qq/'}}\n/; print $str; eval $str; print "\t".$@ if $@; } print Dumper $h;
...results in:
pop @{$h->{'pop'}} shift @{$h->{'shift'}} map {1} @{$h->{'map {1}'}} grep {1} @{$h->{'grep {1}'}} chomp @{$h->{'chomp'}} lc @{$h->{'lc'}} Can't use an undefined value as an ARRAY reference at (eval 7) lin +e 1. localtime @{$h->{'localtime'}} Can't use an undefined value as an ARRAY reference at (eval 8) lin +e 1. cos @{$h->{'cos'}} Can't use an undefined value as an ARRAY reference at (eval 9) lin +e 1. $VAR1 = { 'chomp' => [], 'pop' => [], 'map {1}' => [], 'grep {1}' => [], 'shift' => [] };

In reply to Re^2: Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?" by kikuchiyo
in thread Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?" by kikuchiyo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.