in reply to Re: How & why does this work?
in thread How & why does this work?

Thank you almut ... I tried the example you gave me, it does stop updating.
Also the $path (in my script's foreach) will be a reference because of this optimization... i am i right?

Replies are listed 'Best First'.
Re^3: How & why does this work?
by almut (Canon) on Jul 11, 2008 at 14:30 UTC
    the $path (in my script's foreach) will be a reference (?)

    Not a reference in the normal Perl sense (i.e. you don't need to dereference it), but an alias to the original element (which at a lower level could be thought of as kind of a reference). In other words, modifying $path will modify the original value in the array. This applies in both cases, however (with and without optimisation), because the aliases are being set up to the individual elements, even when the intermediate list on the stack is being created.