in reply to Replacing a given character starting with the xth occurence in a string

Um, I'm pretty new to perl, but your problem is very simple really. I think everyone has tried to make it much more complicated a problem than it really is.

Try this:

#!/usr/perl -w my p$ = 'Terrence and Phillip are sweet'; p$ =~ s/w/1/g;
p$ will then contain "T1rr1nc1 and Phillip ar1 sw11t", I think you'll find.