In the following, the T represents a literal tab character.
/\T/ and /\T/x were being deparsed as /T/ and /T/x.
In the particular case of /\T/x that actually changed the pattern's
meaning.
So don't do that: leave the backslashes alone.
This makes
./TEST -deparse t/re/keep_tabs.t
pass.
# Remove backslashes which precede literal control characters,
# to avoid creating ambiguity when we escape the latter.
+#
+# Don't remove a backslash from escaped whitespace: where the T represents
+# a literal tab character, /T/x is not equivalent to /\T/x
+
sub re_unback {
my($str) = @_;
# only remove if the thing following is a control char
(?=[[:^print:]])
+ # and not whitespace
+ (?=\S)
/$1$2/xg;
return $str;
}
/$a(?{ my($x, $y) = (); })/;
my $r1 = qr/(?{ my($x, $y) = (); })/;
my $r2 = qr/$a(?{ my($x, $y) = (); })/;
+####
+# don't remove pattern whitespace escapes
+/a\ b/;
+/a\ b/x;
+/a\ b/;
+/a\ b/x;