⭐ 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.
This will result in 'A2B1CDEFG'my $padded = 'ABCDEFG'; substr($padded, 2, 0) = '1'; substr($padded, 1, 0) = '2';
|
---|
In Section
Seekers of Perl Wisdom