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????????'
In reply to Re: What is wrong here (Replacing Strin pieces)
by AnomalousMonk
in thread What is wrong here (Replacing Strin pieces)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |