in reply to Replacing a given character starting with the xth occurence in a string
sub adv_tr { my ($str, $x, $from, $to) = @_; my $pos = 0; # find index of Xth "$from" ($pos = index($str, $from, $pos)) == -1 and return while $x--; eval "substr(\$str, $pos) =~ tr/\Q$from\E/\Q$to\E/"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Replacing a given character starting with the xth occurence in a string
by MeowChow (Vicar) on May 21, 2001 at 10:30 UTC | |
by japhy (Canon) on May 21, 2001 at 17:55 UTC |