Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Strange behaviour of interpreter when dereferencing an undefined value

by kejv2 (Acolyte)
on Nov 03, 2014 at 20:43 UTC ( [id://1105942]=note: print w/replies, xml ) Need Help??


in reply to Re: Strange behaviour of interpreter when dereferencing an undefined value
in thread Strange behaviour of interpreter when dereferencing an undefined value

I can't see how this could be related to my examples since in
perl -we'use strict; sub foo {}; my $a; foo( %{ $a } )'
the expression %{ $a } isn't in lvalue context. Also autovivification doesn't appear only in lvalue context:
perl -MData::Dumper -we'use strict; my $a; $a->{b}{c}; print Dumper $a +' $VAR1 = { 'b' => {} };

Replies are listed 'Best First'.
Re^3: Strange behaviour of interpreter when dereferencing an undefined value
by ikegami (Patriarch) on Nov 04, 2014 at 03:38 UTC

    the expression %{ $a } isn't in lvalue context.

    Yes, it is.

    $ perl -E'sub f { $_[0] = 'abc' } f($x); say $x' abc $ perl -E'sub f { $_[1] = 'abc' } $h{a}=undef; f(%h); say $h{a}' abc

    Perl arguments are always passed by reference.

    Also autovivification doesn't appear only in lvalue context

    I didn't say otherwise.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-23 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found