Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Dereferencing undef as an array: Bug or WAD?

by BrowserUk (Patriarch)
on Jun 04, 2008 at 14:01 UTC ( [id://690141]=note: print w/replies, xml ) Need Help??


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.

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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://690141]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2025-03-21 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (63 votes). Check out past polls.