Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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);

Produces:

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


Comment on Re: Why is "undef" after passing not readonly anymore?
Select or Download Code
Re^2: Why is "undef" after passing not readonly anymore?
by LanX (Canon) on Sep 07, 2012 at 08:37 UTC
    Hi

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2015-07-06 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (73 votes), past polls