in reply to changing array size in foreach loop: is it safe?

I can say that it's not a good idea. Look at what you get when you do this:
my @foo = qw/a b c d e f g/; for my $x (@foo) { push @foo, 'd' if $x eq 'd'; print $x; }
The iterator keeps marching through the d's, adding new ones to the end. A better way to do it might be:
push @foo, map {$_ eq 'd' ? 'd' : ()} @foo; print for @foo;
I doubt that it's implmentation-dependent. The iterator is stepping through the array, and by the time it gets to the end of the array, there's another element there to step through.

Still, it's not a nice trick to play. Here's an even more diabolical one:

for (@foo) { print; shift(@foo) if $_ eq 'c'; } print "\n@foo\n";

Caution: Contents may have been coded under pressure.