in reply to Re^2: Substitution, '+' in first position of Pattern
in thread Substitution, '+' in first position of Pattern

Is this what you looking for??
perl -e '$in=quotemeta("+44");$out=$in; $out=~s/\Q$in\E//;print "Result: |$in|$out|\n";' Result: |\+44||

Or

perl -e '$in="+44";$out=$in; $out=~s/\Q$in\E//;print "Result: |$in|$out|\n";' Result: |+44||

Replies are listed 'Best First'.
Re^4: Substitution, '+' in first position of Pattern
by flexvault (Monsignor) on Oct 01, 2010 at 11:13 UTC

    Both JavaFan and suhailck solutions work correctly.

    The quotemata or \Q is what I need in my code. The $in / $out were just to show a sample of the problem. Sorry, I didn't noticed the reversing of pattern at the time, since I got the same error message.

    The actual code has only 1 variable, but without the backslash of '+' my solution didn't work in all case.

    Thank you.