in reply to Can you set a character in a string at a given index directly?
Yes, you can. Read the documentation for the substr function.
UPDATE: a simple example
#!/usr/bin/perl use v5.14; my $string = '0123456789'; my $index = 1; # second character my $replacement = 'x'; substr( $string, $index, # starting from 0 1, # how many characters $replacement, ); say $string; # will print out '0x23456789' as expected
- Luke
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can you set a character in a string at a given index directly?
by tkguifan (Scribe) on Feb 03, 2015 at 16:08 UTC | |
by MidLifeXis (Monsignor) on Feb 03, 2015 at 16:12 UTC |