Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How do I insert characters at certain positions in a string?

by Anonymous Monk
on Sep 16, 2003 at 22:28 UTC ( #291981=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I insert characters at certain positions in a string? - Answer contributed by Anonymous Monk

If you do not want to replace the character you can set the substring length to zero.
my $padded = 'ABCDEFG'; substr($padded, 2, 0) = '1'; substr($padded, 1, 0) = '2';
This will result in 'A2B1CDEFG'

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-02-27 03:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (376 votes). Check out past polls.