flexvault has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I have searched both this list and perlbug, and I don't find anything about this (exactly). The following code 1. works fine and the result is correct. But when I put a '+' character in front of the pattern variable in 2., I get an error.
This is reproducible on all version of perl that I have from 5.6.1 through 5.12.1
Is this an error, or should I be testing for '+' in the first position of the pattern variable? Note: I usually have no idea what /pattern/replacement/ actually contain.
1. perl -e '$in="44"; $out=$in; $out =~ s/$in//; print "Result: |$in|$out|\n";'
Result: |44||
2. perl -e '$in="+44"; $out=$in; $out =~ s/$in//; print "Result: |$in|$out|\n";'
Quantifier follows nothing in regex; marked by <-- HERE in m/+ <-- HERE 44/ at -e line 1.
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Substitution, '+' in first position of Pattern
by DrHyde (Prior) on Oct 01, 2010 at 09:21 UTC | |
by flexvault (Monsignor) on Oct 01, 2010 at 09:48 UTC | |
by JavaFan (Canon) on Oct 01, 2010 at 10:40 UTC | |
by suhailck (Friar) on Oct 01, 2010 at 10:44 UTC | |
by flexvault (Monsignor) on Oct 01, 2010 at 11:13 UTC | |
by Anonymous Monk on Oct 01, 2010 at 10:41 UTC | |
by gobisankar (Acolyte) on Oct 01, 2010 at 10:25 UTC |