in reply to Inserting into an array while stepping through it
You could do it like this by inserting array refs as you go then flatten it back to a plain list afterwards.
my @ary = ( 1, 2, 3 ); for (@ary) { $_ = check($_); } # now flatten the list of mixed array refs and scalars into one list my @tmp; push @tmp, ref $_ ? @$_ : $_ for @ary; @ary = @tmp; print "$_\n" for @ary; sub check { return $_[0] == 2 ? [ 'a', 'b', 'c' ] : $_[0]; } __DATA__ 1 a b c 3
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|