http://www.perlmonks.org?node_id=1004906


in reply to Replace the nth occurence

my $count = 1; my $str = "a,b,c,d"; $str =~ s/((,.*?){$count}),/$1|/; print $str;