in reply to Re: Dereferencing undef as an array: Bug or WAD?
in thread Dereferencing undef as an array: Bug or WAD?

Is it because map code can change the list argument...

That is the implication of ikegami's post.

For a definitive answer we'd need someone from p5p to comfirm that.

Update: That said, if it was being autovivified in the normal sense, you'd expect that either it would persist, or at least values derived from it to persist, but neither is the case:

C:\test>perl -Mstrict -wle "my $r= undef; my @x= map ++$_,@{$r};print qq[[@$r]\n[@x]]" [] []

I think there is a bug there somewhere, but it might be hard to define.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^3: Dereferencing undef as an array: Bug or WAD?
by ChemBoy (Priest) on Jun 04, 2008 at 15:06 UTC

    It does persist—you've autovivified $r as a reference to an array, but that array is still empty:

    % perl -Mstrict -wle 'my $r = undef; map ++$_, @$r; print $r;' ARRAY(0x10116180)