in reply to What is wrong here (Replacing Strin pieces)
For production code, I think I prefer something like rjt's approach, but here's a cute variation:
>perl -wMstrict -le "my $s = '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------'; print qq{'$s'}; ;; $s =~ s{ (?: \G | (?= -+ \z)) - }'?'xmsg; print qq{'$s'}; " '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------' '?????????xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy????????'
|
|---|