[Israel.pm] array manipulation

Anatoly Vorobey mellon at pobox.com
Mon Apr 4 00:36:01 PDT 2005

On Mon, Apr 04, 2005 at 09:50:33AM +0300, Yona Shlomo wrote:
> map { } grep { } map [ ] => sort { } map [ ] => grep { } readdir(DIR);

Argh! My eyes! my eyes!

>         closedir DIR;


> Is the memory allocated for storing the datetime and the
> size being re-used in other parts of this chain or can it be
> reused only after the whole expression is being evaluated
> (actually, only after the next expression begins its
> evaluation)?

Depends on who's calling av_clear for the anonymous array returned
by sort(). My guess would be that it's desroyed immediately after
the subsequent map uses it (and then its members are dereferenced,
and cleared in their turn, and *their* members are dereferenced, and
the memory used fort the scalar values is freed), but that's just a 
guess. If you want to be really sure, you could build a debug perl and 
ask it to dump the opcodes, etc.

"There's nothing simply good, nor ill alone" -- John Donne

More information about the Perl mailing list