in reply to Re^2: How foreach loops decide what to iterate through
in thread How foreach loops decide what to iterate through

You are looping over an array you are adding to, so you are never reaching the end.

This is somewhat similar to the following loop

my $i=1; my $end= 2; while ($i++<$end) { $end++; }

Note that

y @a = (1); foreach (sort @a) { push @a, 1; }

stops immediately, because here you are looping over the anonymous array that is not expanding.