in reply to Replace the nth occurence
Another approach (\K available with 5.10+):
>perl -wMstrict -le "my $nth = 4; my $str = 'a,bb,ccc,dddd,eeeee,ffffff'; ;; --$nth; $str =~ s{ (?: , [^,]*){$nth} \K , }{|}xms; print qq{'$str'}; " 'a,bb,ccc,dddd|eeeee,ffffff'
In Section
Seekers of Perl Wisdom