diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-11-16 15:12:58 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-11-17 13:08:43 -0800 |
commit | c782d7eeebf2d0f63e4373bcef6d31680ef0d3e3 (patch) | |
tree | 777bbe78a94fb33b99db4ad2c8230930a2ffe631 /toke.c | |
parent | c59aba6c624ee10eeb39d2f19d6c1b3f11fd4f07 (diff) | |
download | perl-c782d7eeebf2d0f63e4373bcef6d31680ef0d3e3.tar.gz |
perldiag: \%d better written as $%d
splain can’t necessarily find it if we hard-code the number:
$ ./perl -Ilib -Mdiagnostics -we '()="" =~ s/()()/\1/r'
\1 better written as $1 at -e line 1 (#1)
(W syntax) 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 form
because other Perl programmers will expect it, and it works better if
there are more than 9 backreferences.
$ ./perl -Ilib -Mdiagnostics -we '()="" =~ s/()()/\2/r'
\2 better written as $2 at -e line 1.
$
%d is more intuitive than %c here, so I used %d in the pod instead of
copying the C code that generates it.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -3379,6 +3379,7 @@ S_scan_const(pTHX_ char *start) if (PL_lex_inwhat == OP_SUBST && !PL_lex_inpat && isDIGIT(*s) && *s != '0' && !isDIGIT(s[1])) { + /* diag_listed_as: \%d better written as $%d */ Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX), "\\%c better written as $%c", *s, *s); *--s = '$'; break; |