This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate certain rare uses of backslashes within regexes
authorKarl Williamson <public@khwilliamson.com>
Sun, 20 Jan 2013 03:29:42 +0000 (20:29 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sun, 20 Jan 2013 04:04:27 +0000 (21:04 -0700)
commit4d68ffa0f7f345bc1ae6751744518ba4bc3859bd
treef26602b7dbb509fd5be0a7bf4b3f4e7f29f92a3b
parenta8d9c7ae5b2de9d5434563530be821c884d9a6a7
Deprecate certain rare uses of backslashes within regexes

There are three pairs of characters that Perl recognizes as
metacharacters in regular expression patterns: {}, [], and ().  These
can be used as well to delimit patterns, as in:

 m{foo}
 s(foo)(bar)

Since they are metacharacters, they have special meaning to regular
expression patterns, and it turns out that you can't turn off that
special meaning by the normal means of preceding them with a backslash,
if you use them, paired, within a pattern delimitted by them.  For
example, in

 m{foo\{1,3\}}

the backslashes do not change the behavior, and this matches "f", "o"
followed by one to three more occurrences of "o".

Usages like this, where they are interpreted as metacharacters, are
exceedingly rare; we think there are none, for example, in all of CPAN.
Hence, this deprecation should affect very little code.  It does give
notice, however, that any such code needs to change, which will in turn
allow us to change the behavior in future Perl versions so that the
backslashes do have an effect, and without fear that we are silently
breaking any existing code.

=head1 Performance Enhancements
14 files changed:
dquote_static.c
embed.fnc
embed.h
handy.h
l1_char_class_tab.h
pod/perldelta.pod
pod/perldiag.pod
pod/perlre.pod
proto.h
regcomp.c
regen/mk_PL_charclass.pl
t/lib/warnings/toke
t/re/re_tests
toke.c