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

Re: [perl #79584] perldsc question for Mr Christiansen

Thread Previous
From:
Eric Brine
Date:
November 24, 2010 10:07
Subject:
Re: [perl #79584] perldsc question for Mr Christiansen
Message ID:
AANLkTinFwAAOGVDGZiMBsCzs_hkzzSBx7hyqsdO=gOaH@mail.gmail.com
Hi,

This is list is for the development of Perl itself. For help with
developing in Perl, try perlmonks.org in the future.

> I'm having trouble understanding the difference
> between @{ $AoA[0] } = @array and $AoA[0] = [ @array ]

[] creates an array and a reference to that array. In the former,
you're assigning to an existing array. Thanks to autovivification, the
array will be created if it doesn't already exist.

> Am I missing something in interpreting this as a
> technique to save storage and nothing more?

It doesn't save storage. The former avoids the construction of a new
array and reference.

> Would this technique create a memory leak from the data
> referenced by $$AoA[0]?

No, Perl frees what's no longer being used.

- Eric

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