in reply to Unshift and push inside of map operation.

If you want to iterate over an array you are modifying (of which I won't say it's a smart idea), it may be best to use a C-style for loop. Just remember to increment the loop variable when you are unshifting. Here's an example:
my @a = qw [a1 a2 a3 a4 a5]; for (my $i = 0; $i < @a; $i++) { my $element = $a[$i]; if ($element =~ /[135]/) { push @a, "x"; } else { unshift @a, "y"; $i++; # Don't forget this! } print "array has " . @a . " elements. This one is '$element'\n"; } print "array is now (@a)\n"; __END__ array has 6 elements. This one is 'a1' array has 7 elements. This one is 'a2' array has 8 elements. This one is 'a3' array has 9 elements. This one is 'a4' array has 10 elements. This one is 'a5' array has 11 elements. This one is 'x' array has 12 elements. This one is 'x' array has 13 elements. This one is 'x' array is now (y y y y y a1 a2 a3 a4 a5 x x x)