BernieC has asked for the wisdom of the Perl Monks concerning the following question:
and I can't figure out how to do it. My inclination was to use splice, but splice *removes* the character from the string, so splice($string, n, 1) just won't do. I could doif ({nthcharacter of $string} eq "x")
but that seems really klunky. Am I missing some simple/elegant way to do this?my @b = split(//, $string) ; if ($b[n] eq "x") {...}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nondestructive way to look at a character in a string
by kcott (Archbishop) on Jan 16, 2022 at 11:02 UTC | |
|
Re: nondestructive way to look at a character in a string
by Anonymous Monk on Jan 15, 2022 at 20:06 UTC | |
by BernieC (Pilgrim) on Jan 15, 2022 at 20:54 UTC | |
by ikegami (Patriarch) on Jan 15, 2022 at 21:47 UTC | |
by Anonymous Monk on Jan 16, 2022 at 10:11 UTC |