in reply to Rearranging a string

A regex will do it, if you're careful:
$old .= (length($old) % 2) ? 'F' : ''; $old =~ s/\G(\w)(\w)/$2$1/g;
Note that \w includes letters, digits, and the underscore character. If the latter isn't acceptable, use a character class.