in reply to Repeating a substitution

If the right side of the substitution is constant, split works well, even if the replacement contains the initial value (eg, turn the 10 first | into ||) perl -nE 'print join q(||o||), split q(:), $_, 3' file (as posted on stackoverflow).

Replies are listed 'Best First'.
Re^2: Repeating a substitution
by ikegami (Patriarch) on Jan 09, 2018 at 18:12 UTC

    eg, turn the 10 first | into ||

    The example actually turns the first 2 ":" into "||o||".

      Yes, this was what the OP expected on stack overflow