I have a regex to replace dashes between words with spaces, like this
$newName =~ s/(\w)-(\w)/\1 \2/g;It works fine, but I get a warning saying
\1 better written as $1 at newstuff_rename.pl line 46. \2 better written as $2 at newstuff_rename.pl line 42.
This seems to contradict the documentation, which says:
Although $1 and \1 represent the same thing, care should be taken to use matched variables $1 , $2 ,... only outside a regexp and backreferences \1 , \2 ,... only inside a regexp; not doing so may lead to surprising and unsatisfactory results.
Am I misunderstanding this?
Got it. Thanks for the clarification!
In reply to Regex backreferences by Mad_Mac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |