danj35 has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I'm familiar with Perl's substr and index functions, although I can't seem to find a simple way to combine them in order to match to a specific index within a block of text and then replace this substring with a new piece of text. The only simple way I can think to do it would be using regular expressions, although there's a danger that I'll end up replacing the subtring if it occurs more than once.At present I have a hash with, 'trigger_start', 'trigger_end' and 'trigger_text' for the substring I'm interested in each time. I'm iterating through the substrings backwards so that any replaced text won't need to offset any of the other substring positions.
Thanks very much
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replace text at given index
by Ratazong (Monsignor) on Jun 06, 2011 at 13:43 UTC | |
|
Re: Replace text at given index
by rovf (Priest) on Jun 06, 2011 at 13:49 UTC |