Skip to content

Commit e9b5346

Browse files
author
Abigail
committed
Remove deprecation warnings related to $* and $#.
The magic variables $* and $# were deprecated in 5.000. Their magical meaning was removed in Perl 5.10. Since then, a warning was issued if the variables were used. This warnings has been removed.
1 parent 60a4bc2 commit e9b5346

File tree

5 files changed

+44
-101
lines changed

5 files changed

+44
-101
lines changed

gv.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,13 +2150,6 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
21502150
SvREADONLY_on(av);
21512151
}
21522152
break;
2153-
case '*': /* $* */
2154-
case '#': /* $# */
2155-
if (sv_type == SVt_PV)
2156-
/* diag_listed_as: $* is no longer supported */
2157-
Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
2158-
"$%c is no longer supported", *name);
2159-
break;
21602153
case '\010': /* $^H */
21612154
{
21622155
HV *const hv = GvHVn(gv);
@@ -2263,13 +2256,6 @@ S_maybe_multimagic_gv(pTHX_ GV *gv, const char *name, const svtype sv_type)
22632256
require_tie_mod_s(gv, '!', "Errno", 1);
22642257
else if (*name == '-' || *name == '+')
22652258
require_tie_mod_s(gv, *name, "Tie::Hash::NamedCapture", 0);
2266-
} else if (sv_type == SVt_PV) {
2267-
if (*name == '*' || *name == '#') {
2268-
/* diag_listed_as: $* is no longer supported */
2269-
Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED,
2270-
WARN_SYNTAX),
2271-
"$%c is no longer supported", *name);
2272-
}
22732259
}
22742260
if (sv_type==SVt_PV || sv_type==SVt_PVGV) {
22752261
switch (*name) {

pod/perldeprecation.pod

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,39 @@ To tie the handle, use C<tie *$scalar> (with an explicit asterisk). The same
8181
applies to C<tied *$scalar> and C<untie *$scalar>.
8282

8383

84+
=head2 Perl 5.10
85+
86+
=head3 $* is no longer supported
87+
88+
C<$*> was once a magic variable. C<$*> enabled or disabled
89+
multi-line matching within a string. Deprecated since Perl 5.000,
90+
its special meaning was removed in Perl 5.10. Aftwards, an
91+
deprecation message was issued when using this variable; this message
92+
was discontinued in Perl 5.26.
93+
94+
Instead of using C<$*> you should use the C</m> (and maybe C</s>) regexp
95+
modifiers. You can enable C</m> for a lexical scope (even a whole file)
96+
with C<use re '/m'>. (In older versions: when C<$*> was set to a true value
97+
then all regular expressions behaved as if they were written using C</m>.)
98+
99+
Although you can use C<$*> as a normal variable, you are discouraged
100+
from doing so.
101+
102+
=head3 $# is no longer supported
103+
104+
C<$#> was once a magic variable. C<$#> could be used to format
105+
printed numbers. Deprecated since Perl 5.000,
106+
its special meaning was removed in Perl 5.10. Aftwards, an
107+
deprecation message was issued when using this variable; this message
108+
was discontinued in Perl 5.26.
109+
110+
Instead of using C<$#>, you should be using C<(s)printf> to format
111+
your numbers.
112+
113+
Although you can use C<$*> as a normal variable, you are discouraged
114+
from doing so.
115+
116+
84117
=head1 SEE ALSO
85118

86119
L<warnings>, L<diagnostics>.

pod/perldiag.pod

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,24 +3128,6 @@ You specified a character that has the given plainer way of writing it,
31283128
and which is also portable to platforms running with different character
31293129
sets.
31303130

3131-
=item $* is no longer supported
3132-
3133-
(D deprecated, syntax) The special variable C<$*>, deprecated in older
3134-
perls, has been removed as of 5.10.0 and is no longer supported. In
3135-
previous versions of perl the use of C<$*> enabled or disabled multi-line
3136-
matching within a string.
3137-
3138-
Instead of using C<$*> you should use the C</m> (and maybe C</s>) regexp
3139-
modifiers. You can enable C</m> for a lexical scope (even a whole file)
3140-
with C<use re '/m'>. (In older versions: when C<$*> was set to a true value
3141-
then all regular expressions behaved as if they were written using C</m>.)
3142-
3143-
=item $# is no longer supported
3144-
3145-
(D deprecated, syntax) The special variable C<$#>, deprecated in older
3146-
perls, has been removed as of 5.10.0 and is no longer supported. You
3147-
should use the printf/sprintf functions instead.
3148-
31493131
=item '%s' is not a code reference
31503132

31513133
(W overload) The second (fourth, sixth, ...) argument of

t/lib/warnings/2use

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,19 +361,21 @@ Use of uninitialized value $c in scalar chop at - line 9.
361361
########
362362

363363
# Check that deprecation warnings are not implicitly disabled by use
364-
$*;
364+
our $foo :unique;
365365
use warnings "void";
366-
$#;
366+
our $bar :unique;
367+
$*;
367368
EXPECT
368-
$* is no longer supported at - line 3.
369-
$# is no longer supported at - line 5.
370-
Useless use of a variable in void context at - line 5.
369+
Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 3.
370+
Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 5.
371+
Useless use of a variable in void context at - line 6.
371372
########
372373

373374
# Check that deprecation warnings are not implicitly disabled by no
374-
$*;
375+
our $foo :unique;
375376
no warnings "void";
376-
$#;
377+
our $bar :unique;
378+
$*;
377379
EXPECT
378-
$* is no longer supported at - line 3.
379-
$# is no longer supported at - line 5.
380+
Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 3.
381+
Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 5.

t/lib/warnings/gv

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -59,66 +59,6 @@ EXPECT
5959
Use of inherited AUTOLOAD for non-method main::fᕃƌ() is deprecated at - line 7.
6060
########
6161
# gv.c
62-
$a = ${"#"};
63-
$a = ${"*"};
64-
no warnings 'deprecated' ;
65-
$a = ${"#"};
66-
$a = ${"*"};
67-
EXPECT
68-
$# is no longer supported at - line 2.
69-
$* is no longer supported at - line 3.
70-
########
71-
# gv.c
72-
$a = ${#};
73-
$a = ${*};
74-
no warnings 'deprecated' ;
75-
$a = ${#};
76-
$a = ${*};
77-
EXPECT
78-
$# is no longer supported at - line 2.
79-
$* is no longer supported at - line 3.
80-
########
81-
# gv.c
82-
$a = $#;
83-
$a = $*;
84-
$# = $a;
85-
$* = $a;
86-
$a = \$#;
87-
$a = \$*;
88-
no warnings 'deprecated' ;
89-
$a = $#;
90-
$a = $*;
91-
$# = $a;
92-
$* = $a;
93-
$a = \$#;
94-
$a = \$*;
95-
EXPECT
96-
$# is no longer supported at - line 2.
97-
$* is no longer supported at - line 3.
98-
$# is no longer supported at - line 4.
99-
$* is no longer supported at - line 5.
100-
$# is no longer supported at - line 6.
101-
$* is no longer supported at - line 7.
102-
########
103-
# gv.c
104-
@a = @#;
105-
@a = @*;
106-
$a = $#;
107-
$a = $*;
108-
EXPECT
109-
$# is no longer supported at - line 4.
110-
$* is no longer supported at - line 5.
111-
########
112-
# gv.c
113-
$a = $#;
114-
$a = $*;
115-
@a = @#;
116-
@a = @*;
117-
EXPECT
118-
$# is no longer supported at - line 2.
119-
$* is no longer supported at - line 3.
120-
########
121-
# gv.c
12262
$a = ${^ENCODING};
12363
$a = ${^E_NCODING};
12464
${^ENCODING} = 1;

0 commit comments

Comments
 (0)