Oh, OK, I thought you were inserting a string at the given position. To replace N characters, of course you set the LENGTH parameter to N. For example, to remove 1 element, set LENGTH to 1.
And (just for the sake of completeness), if you want to overwrite the string, you can do this:
splice @chars, $pos, length $insert, $insert;
which will, for example, take inputs of aaacccddd 3 bbb and thequickbrownfox 8 white, and produce outputs of aaabbbddd and thequickwhitefox, respectively.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: Can you set a character in a string at a given index directly?
by Athanasius
in thread Can you set a character in a string at a given index directly?
by tkguifan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |