Apologies if this has been answered here or elsewhere; I did research, but it's one of those hard-to-describe questions for a SE..
Briefly I need to substitute the ordinal match sequence number for each match, like:
cat
dog
cat
mouse
eel
cat
housecat
catamaran
fish
I need a perlvar that has the nth match so I can write something like
s/(cat)/^1/smg
where ^1 would be the number of the nth "cat": matched. In that example I'd get:
1
dog
2
mouse
eel
3
house4
5amaran
fish
OF COURSE I can do this in a loop. Or with a /e.. I want a substitution with a Perlvar of the nth match, if one exists? TYVM!