Front page | perl.perl5.porters |
Postings from November 2010
[perl #79688] [PATCH] Deprecate ?PATTERN? match and warn on usage
Thread Next
From:
David Golden
Date:
November 24, 2010 06:06
Subject:
[perl #79688] [PATCH] Deprecate ?PATTERN? match and warn on usage
Message ID:
rt-3.6.HEAD-13564-1290568677-1331.79688-75-0@perl.org
# New Ticket Created by David Golden
# Please include the string: [perl #79688]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=79688 >
?PATTERN? has been noted as "vaguely deprecated" for a long time
and recent email communication between Jesse Vincent and Larry
Wall confirm the intention that this should have been actually
deprecated long ago.
This patch issues deprecation warnings on ?PATTERN? and updates
the documentation accordingly. Tests that were broken or issuing
warnings have been fixed with C<no warnings 'deprecated'>.
---
pod/perldelta.pod | 5 +++++
pod/perldiag.pod | 5 +++++
pod/perlop.pod | 23 +++++++++++------------
t/op/reset.t | 2 ++
t/re/pat.t | 1 +
t/re/pat_rt_report.t | 1 +
toke.c | 4 ++++
7 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index b1da9b8..1576050 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -53,6 +53,11 @@ listed as an updated module in the L</Modules and Pragmata> section.
[ List each deprecation as a =head2 entry ]
+=head2 ?PATTERN? match syntax is deprecated
+
+The C<?PATTERN?> match syntax was "vaguely" deprecated for years and is
+now formally deprecated and warns on usage.
+
=head1 Performance Enhancements
XXX Changes which enhance performance without changing behaviour go here. There
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index e08fe1e..393bb5f 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -3494,6 +3494,11 @@ to even) byte length.
(F) Parsing code supplied by an extension violated the parser's API in
a detectable way.
+=item ?PATTERN? match syntax is deprecated
+
+(D deprecated) You have used ?PATTERN? match syntax, which has been
+deprecated and should no longer be used.
+
=item Pattern subroutine nesting without pos change exceeded limit in regex; marked by <-- HERE in m/%s/
(F) You used a pattern that uses too many nested subpattern calls without
diff --git a/pod/perlop.pod b/pod/perlop.pod
index c577f36..fb3a9b0 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -1357,14 +1357,14 @@ process modifiers are available:
g Match globally, i.e., find all occurrences.
c Do not reset search position on a failed match when /g is in effect.
-If "/" is the delimiter then the initial C<m> is optional. With the C<m>
-you can use any pair of non-whitespace characters
-as delimiters. This is particularly useful for matching path names
-that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is
-the delimiter, then the match-only-once rule of C<?PATTERN?> applies.
-If "'" is the delimiter, no interpolation is performed on the PATTERN.
-When using a character valid in an identifier, whitespace is required
-after the C<m>.
+If "/" is the delimiter then the initial C<m> is optional. With the
+C<m> you can use any pair of non-whitespace characters as delimiters.
+This is particularly useful for matching path names that contain "/",
+to avoid LTS (leaning toothpick syndrome). If "'" is the delimiter,
+no interpolation is performed on the PATTERN. When using a character
+valid in an identifier, whitespace is required after the C<m>. If "?"
+is the delimiter, then the match-only-once rule of C<?PATTERN?>
+applies, but this usage has been deprecated.
PATTERN may contain variables, which will be interpolated (and the
pattern recompiled) every time the pattern search is evaluated, except
@@ -1525,7 +1525,7 @@ Here is the output (split into several lines):
lowercase line-noise lowercase lowercase line-noise lowercase
lowercase line-noise MiXeD line-noise. That's all!
-=item ?PATTERN?
+=item ?PATTERN? (DEPRECATED)
X<?>
This is just like the C</pattern/> search, except that it matches only
@@ -1542,9 +1542,8 @@ patterns local to the current package are reset.
reset if eof; # clear ?? status for next file
}
-This usage is vaguely deprecated, which means it just might possibly
-be removed in some distant future version of Perl, perhaps somewhere
-around the year 2168.
+This usage is deprecated and may be removed in a future version of Perl.
+Using C<?PATTERN?> will result in a warning.
=item s/PATTERN/REPLACEMENT/msixpogcer
X<substitute> X<substitution> X<replace> X<regexp, replace>
diff --git a/t/op/reset.t b/t/op/reset.t
index 029161a..6a363c5 100644
--- a/t/op/reset.t
+++ b/t/op/reset.t
@@ -6,6 +6,7 @@ BEGIN {
require './test.pl';
}
use strict;
+no warnings 'deprecated';
# Currently only testing the reset of patterns.
plan tests => 24;
@@ -85,6 +86,7 @@ __DATA__
#!perl
use warnings;
use strict;
+no warnings 'deprecated';
# Note that there are no digits in this program, other than the placeholders
sub a {
diff --git a/t/re/pat.t b/t/re/pat.t
index 5024112..050aff4 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -88,6 +88,7 @@ sub run_tests {
}
{
+ no warnings 'deprecated';
our %XXX = map {($_ => $_)} 123, 234, 345;
our @XXX = ('ok 1','not ok 1', 'ok 2','not ok 2','not ok 3');
diff --git a/t/re/pat_rt_report.t b/t/re/pat_rt_report.t
index df99d9c..97cf516 100644
--- a/t/re/pat_rt_report.t
+++ b/t/re/pat_rt_report.t
@@ -221,6 +221,7 @@ sub run_tests {
{
+ no warnings 'deprecated';
local $BugId = "20020412.005";
local $Message = "Correct pmop flags checked when empty pattern";
diff --git a/toke.c b/toke.c
index 70b1dfd..2a28ea4 100644
--- a/toke.c
+++ b/toke.c
@@ -11951,6 +11951,10 @@ S_scan_pat(pTHX_ char *start, I32 type)
mg->mg_len = elements * sizeof(PMOP**);
PmopSTASH_set(pm,PL_curstash);
}
+ if (ckWARN_d(WARN_DEPRECATED)) {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), "%s",
+ "?PATTERN? match syntax is deprecated");
+ }
}
#ifdef PERL_MAD
modstart = s;
--
1.7.1
Thread Next
-
[perl #79688] [PATCH] Deprecate ?PATTERN? match and warn on usage
by David Golden