Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

( #16932=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > How do I insert characters at certain positions in a string? contributed by mdillon

my $padded = ' ' x 5; substr($padded, 2, 1) = 'A'; substr($padded, 1, 1) = 'B';
Will result in: ' BA  '

Comment on Answer: How do I insert characters at certain positions in a string?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2015-07-30 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls