Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by mdillon (Priest)
on Jun 07, 2000 at 22:47 UTC ( #16932=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 mdillon

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

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
NodeReaper edits tomorrow's obituaries

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-02-25 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (366 votes). Check out past polls.