in reply to Replace the nth occurence
Maybe I'm boring ... but I prefer more explicit code with split-and-join over regex-acrobatics:
my $nth = 4; my $str = 'a,bb,ccc,dddd,eeeee,ffffff'; my @str= split /,/,$str; $str = join ( "," , @str[0..$nth-1] ) . "|" . join ( "," , @str[$nth.. +$#str] ); print qq{'$str'};
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replace the nth occurence
by AnomalousMonk (Archbishop) on Nov 23, 2012 at 06:22 UTC | |
by LanX (Saint) on Nov 23, 2012 at 14:03 UTC |