Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

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


in reply to How do I insert characters at certain positions in a string?

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
Node Status?
node history
Node Type: note [id://291981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2021-04-21 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?