in reply to PUZZLED

How about 'mod'?
$direction = 1; #set to -1 to go to opposite direction @array = split(//, $string); for (@array) { print $array[$i]; $i = ($i + $direction) % ($#array + 1); };
You have to initialize $i.

UPDATED: Added $direction (I think I was going backwards first)