in reply to Re^2: Substitution, '+' in first position of Pattern
in thread Substitution, '+' in first position of Pattern
Note that '$in' is the pattern, not the original value of '$out'.$ perl -le '$out = "+44"; $in=quotemeta $out; $out =~ s/$in//; print " +Result: |$in|$out|\n";' Result: |\+44||
Alternatively, you may write:
$ perl -le '$in = "+44"; $out = $in; $out =~ s/\Q$in//; print "Result: + |$in|$out|\n";' Result: |+44||
|
|---|