How do you enter text before and after each character in a string in Perl?

  • Thread starter Thread starter The_Chef
  • Start date Start date
T

The_Chef

Guest
How do you enter text before and after each character in a string in perl?
for example: The string to be inputted, BEFORE the each char is "1", and AFTER each character is "2".

The string entered is : "A big dog"
Result should be : 1A2 1b21i21g2 1d21o21g2
 
You don't "enter" it at all. Just construct a completely new string. Break the entered string into characters, and add each character and the separators to the new string.
 
You don't "enter" it at all. Just construct a completely new string. Break the entered string into characters, and add each character and the separators to the new string.
 
Back
Top