$temp = chop($word) . $temp, print "$temp$word\n" while $word; # $temp and $word should, of course, be initialized.