develooper Front page | perl.perl5.porters | Postings from January 2010

Re: Re[2]: memory problem of "eval" in perl 5.10? Solved (with one new question ;-))

Thread Previous
From:
Eric Brine
Date:
January 19, 2010 09:28
Subject:
Re: Re[2]: memory problem of "eval" in perl 5.10? Solved (with one new question ;-))
Message ID:
f86994701001190927j4771ac0eve448c950b90e32eb@mail.gmail.com
On Tue, Jan 19, 2010 at 11:28 AM, <christian4perl@lists.muthpartners.de>wrote:

>   have a simple (?) question (it can be, that that is OT here; if it so,
> please tell me where I right).


http://www.perlmonks.org/


> The above dumped perl code looks like the
> following scriplet:
>
> $obj = bless({ '_request' => bless({'_uri' => bless ( "...", 'URI::http' )
>       , '_uri_canonical' => $obj->{'_request'}{'_uri'}
> }, 'HTTP::Request' ) }, 'HTTP::Response' )
>
> How can perl's eval evaluate this code, at all?


Assuming $obj is initially undef,

$obj will be autovivified
$obj->{'_request'} will be autovivified
$obj->{'_request'}{'_uri'} will return undef.
$obj will be overwritten

You might as well have written

$obj = bless({ '_request' => bless({'_uri' => bless ( "...", 'URI::http' )
      , '_uri_canonical' => undef
}, 'HTTP::Request' ) }, 'HTTP::Response' )

That's why you need to use Purity = 1 when using DD to generate code rather
than using it to debug.


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About