This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldiag: \%d better written as $%d
authorFather Chrysostomos <sprout@cpan.org>
Sat, 16 Nov 2013 23:12:58 +0000 (15:12 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 17 Nov 2013 21:08:43 +0000 (13:08 -0800)
commitc782d7eeebf2d0f63e4373bcef6d31680ef0d3e3
tree777bbe78a94fb33b99db4ad2c8230930a2ffe631
parentc59aba6c624ee10eeb39d2f19d6c1b3f11fd4f07
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.
pod/perldiag.pod
t/porting/diag.t
toke.c