summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-06-13 19:17:50 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-06-13 19:17:50 +0000
commitf02c194e1a40f11d020685cd18b41e5261091b12 (patch)
tree37863ea19d4769893b861e11cb30b0215621246d
parentcff1be36840a17022b50a6f295ed97efe19b975e (diff)
downloadperl-f02c194e1a40f11d020685cd18b41e5261091b12.tar.gz
Remove the deprecated $* variable.
Incidentally, this fixes bug #22354, about unwanted action-at-distance of the /m regexp modifier. Add a new warning to advertise this fact. p4raw-id: //depot/perl@19769
-rw-r--r--gv.c12
-rw-r--r--lib/English.pm1
-rw-r--r--mg.c6
-rw-r--r--pod/perldelta.pod9
-rw-r--r--pod/perldiag.pod13
-rw-r--r--pod/perlre.pod12
-rw-r--r--pod/perlvar.pod20
-rw-r--r--pp.c2
-rw-r--r--pp_hot.c4
-rw-r--r--t/lib/warnings/gv4
-rwxr-xr-xt/op/pat.t25
-rwxr-xr-xt/op/study.t9
12 files changed, 50 insertions, 67 deletions
diff --git a/gv.c b/gv.c
index a003e8e885..b944d44f05 100644
--- a/gv.c
+++ b/gv.c
@@ -925,10 +925,15 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
SvREADONLY_on(av);
}
goto magicalize;
- case '#':
case '*':
- if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX) && len == 1 && sv_type == SVt_PV)
- Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), "Use of $%s is deprecated", name);
+ if (len == 1 && sv_type == SVt_PV && ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
+ Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
+ "$* has been removed");
+ break;
+ case '#':
+ if (len == 1 && sv_type == SVt_PV && ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
+ Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
+ "Use of $# is deprecated");
/* FALL THROUGH */
case '[':
case '^':
@@ -1837,7 +1842,6 @@ Perl_is_gv_magical(pTHX_ char *name, STRLEN len, U32 flags)
case '!':
case '-':
case '#':
- case '*':
case '[':
case '^':
case '~':
diff --git a/lib/English.pm b/lib/English.pm
index 6cd3acda53..6b479ee34e 100644
--- a/lib/English.pm
+++ b/lib/English.pm
@@ -224,7 +224,6 @@ sub import {
# *ARRAY_BASE = *[ ;
# *OFMT = *# ;
-# *MULTILINE_MATCHING = ** ;
# *OLD_PERL_VERSION = *] ;
1;
diff --git a/mg.c b/mg.c
index eee140bdf5..ba576c3707 100644
--- a/mg.c
+++ b/mg.c
@@ -892,8 +892,6 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
#endif
(void)SvIOK_on(sv); /* what a wonderful hack! */
break;
- case '*':
- break;
#ifndef MACOS_TRADITIONAL
case '0':
break;
@@ -2143,10 +2141,6 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
}
}
break;
- case '*':
- i = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
- PL_multiline = (i != 0);
- break;
case '/':
SvREFCNT_dec(PL_rs);
PL_rs = newSVsv(sv);
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 8704322575..444dcf9e26 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -9,6 +9,11 @@ the 5.9.0 release.
=head1 Incompatible Changes
+=head2 The C<$*> variable has been removed
+
+C<$*>, which was deprecated in favor of the C</s> and C</m> regexp
+modifiers, has been removed.
+
=head1 Core Enhancements
=head2 Tied Arrays with Negative Array Indices
@@ -48,8 +53,8 @@ C<EXISTS>, and C<DELETE> unchanged.
If you find what you think is a bug, you might check the articles
recently posted to the comp.lang.perl.misc newsgroup and the perl
-bug database at http://bugs.perl.org/ . There may also be
-information at http://www.perl.com/ , the Perl Home Page.
+bug database at F<http://bugs.perl.org/>. There may also be
+information at F<http://www.perl.com/>, the Perl Home Page.
If you believe you have an unreported bug, please run the B<perlbug>
program included with your release. Be sure to trim your bug down
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 4d9501644b..0669db62c3 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1640,6 +1640,12 @@ supposed to follow something: a template character or a ()-group.
to have existed already, but for some reason it didn't, and had to be
created on an emergency basis to prevent a core dump.
+=item $* has been removed
+
+(D deprecated) The special variable C<$*>, deprecated in older perls, has
+been removed as of 5.9.0 and is no longer supported. You should use the
+C<//m> and C<//s> regexp modifiers instead.
+
=item Hash %%s missing the % in argument %d of %s()
(D deprecated) Really old Perl let you omit the % on hash names in some
@@ -4225,13 +4231,6 @@ C<use AutoLoader 'AUTOLOAD';>.
(F) You attempted to use a feature of printf that is accessible from
only C. This usually means there's a better way to do it in Perl.
-=item Use of $* is deprecated
-
-(D deprecated) This variable magically turned on multi-line pattern
-matching, both for you and for any luckless subroutine that you happen
-to call. You should use the new C<//m> and C<//s> modifiers now to do
-that without the dangerous action-at-a-distance effects of C<$*>.
-
=item Use of $# is deprecated
(D deprecated) This was an ill-advised attempt to emulate a poorly
diff --git a/pod/perlre.pod b/pod/perlre.pod
index 17a94252cf..a11e3e833b 100644
--- a/pod/perlre.pod
+++ b/pod/perlre.pod
@@ -41,11 +41,7 @@ line anywhere within the string.
Treat string as single line. That is, change "." to match any character
whatsoever, even a newline, which normally it would not match.
-The C</s> and C</m> modifiers both override the C<$*> setting. That
-is, no matter what C<$*> contains, C</s> without C</m> will force
-"^" to match only at the beginning of the string and "$" to match
-only at the end (or just before a newline at the end) of the string.
-Together, as /ms, they let the "." match any character whatsoever,
+Used together, as /ms, they let the "." match any character whatsoever,
while still allowing "^" and "$" to match, respectively, just after
and just before newlines within the string.
@@ -103,13 +99,11 @@ string as a multi-line buffer, such that the "^" will match after any
newline within the string, and "$" will match before any newline. At the
cost of a little more overhead, you can do this by using the /m modifier
on the pattern match operator. (Older programs did this by setting C<$*>,
-but this practice is now deprecated.)
+but this practice has been removed in perl 5.9.)
To simplify multi-line substitutions, the "." character never matches a
newline unless you use the C</s> modifier, which in effect tells Perl to pretend
-the string is a single line--even if it isn't. The C</s> modifier also
-overrides the setting of C<$*>, in case you have some (badly behaved) older
-code that sets it in another module.
+the string is a single line--even if it isn't.
The following standard quantifiers are recognized:
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index 3b9ed060af..6e2a853007 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -294,26 +294,6 @@ past where $2 ends, and so on. You can use C<$#+> to determine
how many subgroups were in the last successful match. See the
examples given for the C<@-> variable.
-=item $MULTILINE_MATCHING
-
-=item $*
-
-Set to a non-zero integer value to do multi-line matching within a
-string, 0 (or undefined) to tell Perl that it can assume that strings
-contain a single line, for the purpose of optimizing pattern matches.
-Pattern matches on strings containing multiple newlines can produce
-confusing results when C<$*> is 0 or undefined. Default is undefined.
-(Mnemonic: * matches multiple things.) This variable influences the
-interpretation of only C<^> and C<$>. A literal newline can be searched
-for even when C<$* == 0>.
-
-Use of C<$*> is deprecated in modern Perl, supplanted by
-the C</s> and C</m> modifiers on pattern matching.
-
-Assigning a non-numerical value to C<$*> triggers a warning (and makes
-C<$*> act if C<$* == 0>), while assigning a numerical value to C<$*>
-makes that an implicit C<int> is applied on the value.
-
=item HANDLE->input_line_number(EXPR)
=item $INPUT_LINE_NUMBER
diff --git a/pp.c b/pp.c
index ef8a37db67..eccf7eb0c9 100644
--- a/pp.c
+++ b/pp.c
@@ -4553,7 +4553,7 @@ PP(pp_split)
s++;
}
}
- if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
+ if ((pm->op_pmflags & PMf_MULTILINE) != PL_multiline) {
SAVEINT(PL_multiline);
PL_multiline = pm->op_pmflags & PMf_MULTILINE;
}
diff --git a/pp_hot.c b/pp_hot.c
index fc2b9c5925..e781dcc0d5 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1234,7 +1234,7 @@ PP(pp_match)
if (SvSCREAM(TARG))
r_flags |= REXEC_SCREAM;
- if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
+ if ((pm->op_pmflags & PMf_MULTILINE) != PL_multiline) {
SAVEINT(PL_multiline);
PL_multiline = pm->op_pmflags & PMf_MULTILINE;
}
@@ -1979,7 +1979,7 @@ PP(pp_subst)
? REXEC_COPY_STR : 0;
if (SvSCREAM(TARG))
r_flags |= REXEC_SCREAM;
- if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
+ if ((pm->op_pmflags & PMf_MULTILINE) != PL_multiline) {
SAVEINT(PL_multiline);
PL_multiline = pm->op_pmflags & PMf_MULTILINE;
}
diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv
index 5ed4eca018..8d2fef5601 100644
--- a/t/lib/warnings/gv
+++ b/t/lib/warnings/gv
@@ -9,7 +9,7 @@
fred() ;
Use of $# is deprecated
- Use of $* is deprecated
+ $* has been removed
$a = ${"#"} ;
$a = ${"*"} ;
@@ -51,4 +51,4 @@ $a = ${"#"};
$a = ${"*"};
EXPECT
Use of $# is deprecated at - line 3.
-Use of $* is deprecated at - line 4.
+$* has been removed at - line 4.
diff --git a/t/op/pat.t b/t/op/pat.t
index 006e1b600f..ccf57a17d5 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -6,7 +6,7 @@
$| = 1;
-print "1..998\n";
+print "1..1004\n";
BEGIN {
chdir 't' if -d 't';
@@ -20,9 +20,8 @@ $x = "abc\ndef\n";
if ($x =~ /^abc/) {print "ok 1\n";} else {print "not ok 1\n";}
if ($x !~ /^def/) {print "ok 2\n";} else {print "not ok 2\n";}
-$* = 1;
-if ($x =~ /^def/) {print "ok 3\n";} else {print "not ok 3\n";}
-$* = 0;
+# used to be a test for $*
+if ($x =~ /^def/m) {print "ok 3\n";} else {print "not ok 3\n";}
$_ = '123';
if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";}
@@ -69,9 +68,8 @@ if (m|bc/*d|) {print "ok 22\n";} else {print "not ok 22\n";}
if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
-$* = 1; # test 3 only tested the optimized version--this one is for real
-if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";}
-$* = 0;
+# used to be a test for $*
+if ("ab\ncd\n" =~ /^cd/m) {print "ok 24\n";} else {print "not ok 24\n";}
$XXX{123} = 123;
$XXX{234} = 234;
@@ -3172,4 +3170,15 @@ ok("bbbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
ok("\x{100}X" =~ /$re/, "S_cl_and ANYOF_UNICODE & ANYOF_INVERTED");
}
-# last test 998
+# bug #22354
+sub func ($) {
+ ok( "a\nb" !~ /^b/, $_[0] );
+ ok( "a\nb" =~ /^b/m, "$_[0] - with /m" );
+}
+func "standalone";
+$_ = "x"; s/x/func "in subst"/e;
+$_ = "x"; s/x/func "in multiline subst"/em;
+#$_ = "x"; /x(?{func "in regexp"})/;
+#$_ = "x"; /x(?{func "in multiline regexp"})/m;
+
+# last test 1004
diff --git a/t/op/study.t b/t/op/study.t
index c93e4f63d2..17c59daa88 100755
--- a/t/op/study.t
+++ b/t/op/study.t
@@ -55,9 +55,8 @@ study($x);
ok($x =~ /^abc/);
ok($x !~ /^def/);
-$* = 1;
-ok($x =~ /^def/);
-$* = 0;
+# used to be a test for $*
+ok($x =~ /^def/m);
$_ = '123';
study;
@@ -102,8 +101,8 @@ ok(m|bc/*d|);
ok(/^$_$/);
-$* = 1; # test 3 only tested the optimized version--this one is for real
-ok("ab\ncd\n" =~ /^cd/);
+# used to be a test for $*
+ok("ab\ncd\n" =~ /^cd/m);
if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'MacOS') {
# Even with the alarm() OS/390 and BS2000 can't manage these tests