http://qs321.pair.com?node_id=638593


in reply to Another puzzled RegEx Problem.

No solution here, but the challenge would be to find the solution that has
--Artist

Replies are listed 'Best First'.
Re^2: Another puzzled RegEx Problem.
by ikegami (Patriarch) on Sep 12, 2007 at 17:12 UTC

    No external loop, no reverse and nothing but "-" in the substitution part:

    $d =~ s/(?!^|$)(?(?{ pos() % 2 })(?!))/-/g;

    Update: Bug fix. I originally forgot to prevent "-" from being placed at the end.

      cool