> =head1 ABSTRACT
>
> Currently, C<\1> and $1 have only slightly different meanings within a
> regex. Let's consolidate them together, eliminate the differences, and
> settle on $1 as the standard.
Sigh. That would remove functionality from the language.
The reason why you need \1 in a regular expression is that $1, $2, ...
are interpolated from the previous regular expression. This allows me
to do a pattern match that captures variables, then use the results of
that to create a second regular expression. (Remember: A regexp
interpolates first, then compiles the pattern).
To come up with a silly example:
if ($line =~ /<TR class='(\w+)'>/i) {
if ($line =~ /<(P|DIV|SPAN) class='$1'>.*?<\/\1>/i) {
^^
The class from the previous regexp
...
}
}
If we implement this RFC, this would no longer be possible without the
use of an extra variable to store the first $1. Interpolation for
regular expressions would no longer work the same as it is for
double-quoted strings.
Hildo