in reply to Is it safe to append to the array you are iterating over
not a good idea!
DB<104> @arr = qw/a b c/; => ("a", "b", "c") DB<105> foreach ( "x",@arr,"y") { push @arr, 'd' if $_ eq 'a'; push @arr, 'e' if $_ eq 'b'; push @arr, 'f' if $_ eq 'c'; print $_; } => "" xabcy
better rely on orthogonal behavior!
Cheers Rolf
( addicted to the Perl Programming Language)
|
---|
In Section
Seekers of Perl Wisdom