in reply to replace nth occurrence of |
Regarding your code, I don't understand your regexes and you didn't provide sample data... (or maybe you need to format more readable)
you are applying multiple /g regexes in a row, after substituting the 10th pipe the 11th pipe becomes the 10th, so better do it in one run.
what is !- supposed to mean???
took me a while to understand that you are negating a decremented counter !(--$pos) ...
If you just swapped the ternary operator you wouldn't need any negation.
Better consider checking ranges in just one single run /($count++ >9 and $count <12) ? 'pipe' : $1/
split and join is still the readable way to do it.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
|
|---|