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

The following works without using any explicit iterations. I haven't clocked its execution against the others, though.
$s = 'abc nbc cbs fox hbo sho cnn rox'; ($orig, $num, $subst) = ('n', 2, '-'); $s =~ s/^(([^$orig]*$orig){$num})(.*)/$1/; ($t = $3) =~ s/$orig/$subst/g; $s .= $t; print $s
This prints:
abc nbc cbs fox hbo sho cn- rox
It works by cutting the string into two parts, applying the substitution to the second part (if there is one) and rejoining them.