in reply to Re: What is wrong here (Replacing Strin pieces)
in thread What is wrong here (Replacing Strin pieces)
$string =~ s/\A(-+)|(-+)$/("?" x length $1).("?" x length $2)/eg;
That does the substitutions, but will also produce warnings if run with warnings:
>perl -wMstrict -le "my $s = '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------'; print qq{'$s'}; ;; $s =~ s{ \A (-+) | (-+) \z } { ('?' x length $1) . ('?' x length $2) }xmsge; print qq{'$s'}; " '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------' Use of uninitialized value $2 in repeat (x) at -e line 1. Use of uninitialized value $1 in repeat (x) at -e line 1. '?????????xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy????????'
|
|---|