I think that it means that foreach (#blah alah blah) created an anonymous array, that can be reused :) I don't know if it is a bug or a feature of Perl :)

The anonymous array is not created only in the case of for(number..number), as ikegami mentioned, as such loops are replaced by counting ones.

The shortest illustrating example:

for (0..2) { foreach my $x (0..1, ()) { print +($x .= " wassap? ") . "\n"; } }

It prints:
0 wassap? 1 wassap? 0 wassap? wassap? 1 wassap? wassap? 0 wassap? wassap? wassap? 1 wassap? wassap? wassap?
UPDATE:

B::Deparse displays that it ocuurs only to arrays generated by the .. operator.

UPDATE 2:

I just realised that i used the feature of modifyable '..' arrays in my code :)

print map { s/$/\n/;$_ } (0..1);
works, while
print map { s/$/\n/;$_ } (0,1);
produces a fatal error :) So we can create one more example:
for (0..1) { print map { s/$/!\n/;$_ } (0..1); }

The bug is that anonymous arrays created by .. are globally scoped :) and I don't think it'a an optimisation for Perl.

Finally, i think that the title of the node is incorrect :)). The good title would be Unexpected behavior of '..' lists. Or smth like this :)


     s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

In reply to Re: Unexpected behaviour with constant lists and foreach (and closures?) by Ieronim
in thread Unexpected behavior of '..' lists by Crackers2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.