Personally I would split on colon first, replace the first part and print out all parts again instead of a second replace like you do.
Anyway for a one liner like you've shown you could use the eval modifier in substitute to run a replacement in the match only.
Something like s# ^([^:]+) # $1 =~ tr/-/_/ #xe
That's untested, not sure if $1 is a read only value and don't know all tr options by heart.
try the r modifier with an embedded s/// then or copy to another var.
hope you got the idea. :)
A "pure" regex without eval could probably work with \K meta in the regex to continue searching after each hyphen.
Or by combining look around assertions.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In reply to Re: Repeated substitution on 1 side of a line only
by LanX
in thread Repeated substitution on 1 side of a line only
by dspivey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |