in reply to Re: More than one way to do it???
in thread More than one way to do it???

That explanation isn't accurate. Perl complains about using \1 in the right-hand side of a substitution because using $1 is preferred. Whether the script is entered on the command line or not isn't important.
#!perl -w use diagnostics; $_ = 'foo'; s/(.)/\1/;
This script produces the following output:
\1 better written as $1 at tmp.pl line 5 (#1) (W) Outside of patterns, backreferences live on as variables. The + use of backslashes is grandfathered on the right-hand side of a substitution, but stylistically it's better to use the variable fo +rm because other Perl programmers will expect it, and it works better if there are more than 9 backreferences.

Replies are listed 'Best First'.