Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Why is "undef" after passing not readonly anymore?

by philiprbrenan (Monk)
on Sep 06, 2012 at 00:34 UTC ( #991980=note: print w/replies, xml ) Need Help??

in reply to Why is "undef" after passing not readonly anymore?

It's to permit autovivification:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); sub aaa($) {my ($a) = @_; $a->{a} = 1; say STDERR dump($a); } aaa({}); aaa(undef); aaa(0);


{ a => 1 } { a => 1 } Can't use string ("0") as a HASH ref while "strict refs" in use at C:\ +Phil\Perl\PerlMonks\ line 8.

Replies are listed 'Best First'.
Re^2: Why is "undef" after passing not readonly anymore?
by LanX (Chancellor) on Sep 07, 2012 at 08:37 UTC

    Good point, but I think it's even simpler!

    There are so many cases where undef is occasionally passed as argument, that inner variables of a sub like $_[0] must be writable.

    Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991980]
marto does the "it's almost home time" dance

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-07-21 15:59 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (328 votes). Check out past polls.