Shlomi Fish  committed 8051b11

Add more.

  • Participants
  • Parent commits 09d8925

Comments (0)

Files changed (1)

File src/tutorials/bad-elements/index.html.wml

+<item id="backslash_n_on_rhs" h="Using \\1 instead of $1 on the Right Hand Side of a Substitution">
+There is no good reason to use <code>\\1</code>, <code>\\2</code>, etc. in the
+right-hand-side of a substitution instead of <code>$1</code> <code>$2</code>
+etc. While this may work, the backslash-digits variables are aimed at
+back-references, such as matching the exact string of a capture again within
+the left hand side of a regex:
+$s =~ s/(H\w+)\s+(W\w+)/\1 [=] \2/;
+Better code:
+$s =~ s/(H\w+)\s+(W\w+)/$1 [=] $2/;
 <item id="premature_optimization" h="Premature Optimisation">