Syntactic Confectionery Delight | |
PerlMonks |
Re^2: Why doesn't this die with "Can't use an undefined value as an ARRAY reference"?"by kikuchiyo (Hermit) |
on Oct 18, 2017 at 20:56 UTC ( [id://1201619]=note: print w/replies, xml ) | Need Help?? |
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: ...results in:
In Section
Seekers of Perl Wisdom
|
|