1PERLDEPRECATION(1)     Perl Programmers Reference Guide     PERLDEPRECATION(1)
2
3
4

NAME

6       perldeprecation - list Perl deprecations
7

DESCRIPTION

9       The purpose of this document is to document what has been deprecated in
10       Perl, and by which version the deprecated feature will disappear, or,
11       for already removed features, when it was removed.
12
13       This document will try to discuss what alternatives for the deprecated
14       features are available.
15
16       The deprecated features will be grouped by the version of Perl in which
17       they will be removed.
18
19   Perl 5.40
20       Downgrading a "use VERSION" to below v5.11
21
22       Once Perl has seen a "use VERSION" declaration that requests a version
23       "v5.11" or above, a subsequent second declaration that requests an
24       earlier version will print a deprecation warning. For example,
25
26           use v5.14;
27           say "We can use v5.14's features here";
28
29           use v5.10;        # This prints a warning
30
31       This behaviour will be removed in Perl 5.40; such a subsequent request
32       will become a compile-time error.
33
34       This is because of an intended related change to the interaction
35       between "use VERSION" and "use strict". If you specify a version >=
36       5.11, strict is enabled implicitly. If you request a version < 5.11,
37       strict will become disabled even if you had previously written "use
38       strict". This was not the previous behaviour of "use VERSION", which at
39       present will track explicitly-enabled strictness flags independently.
40
41   Perl 5.38
42       Pod::Html utility functions
43
44       The definition and documentation of three utility functions previously
45       importable from Pod::Html were moved to new package Pod::Html::Util in
46       Perl 5.36.  While they remain importable from Pod::Html in Perl 5.36,
47       as of Perl 5.38 they will only be importable, on request, from
48       Pod::Html::Util.
49
50   Perl 5.34
51       There are no deprecations or fatalizations scheduled for Perl 5.34.
52
53   Perl 5.32
54       Constants from lexical variables potentially modified elsewhere
55
56       You wrote something like
57
58           my $var;
59           $sub = sub () { $var };
60
61       but $var is referenced elsewhere and could be modified after the "sub"
62       expression is evaluated.  Either it is explicitly modified elsewhere
63       ("$var = 3") or it is passed to a subroutine or to an operator like
64       "printf" or "map", which may or may not modify the variable.
65
66       Traditionally, Perl has captured the value of the variable at that
67       point and turned the subroutine into a constant eligible for inlining.
68       In those cases where the variable can be modified elsewhere, this
69       breaks the behavior of closures, in which the subroutine captures the
70       variable itself, rather than its value, so future changes to the
71       variable are reflected in the subroutine's return value.
72
73       If you intended for the subroutine to be eligible for inlining, then
74       make sure the variable is not referenced elsewhere, possibly by copying
75       it:
76
77           my $var2 = $var;
78           $sub = sub () { $var2 };
79
80       If you do want this subroutine to be a closure that reflects future
81       changes to the variable that it closes over, add an explicit "return":
82
83           my $var;
84           $sub = sub () { return $var };
85
86       This usage was deprecated and as of Perl 5.32 is no longer allowed.
87
88       Use of strings with code points over 0xFF as arguments to "vec"
89
90       "vec" views its string argument as a sequence of bits.  A string
91       containing a code point over 0xFF is nonsensical.  This usage is
92       deprecated in Perl 5.28, and was removed in Perl 5.32.
93
94       Use of code points over 0xFF in string bitwise operators
95
96       The string bitwise operators, "&", "|", "^", and "~", treat their
97       operands as strings of bytes. As such, values above 0xFF are
98       nonsensical. Some instances of these have been deprecated since Perl
99       5.24, and were made fatal in 5.28, but it turns out that in cases where
100       the wide characters did not affect the end result, no deprecation
101       notice was raised, and so remain legal.  Now, all occurrences either
102       are fatal or raise a deprecation warning, so that the remaining legal
103       occurrences became fatal in 5.32.
104
105       An example of this is
106
107        "" & "\x{100}"
108
109       The wide character is not used in the "&" operation because the left
110       operand is shorter.  This now throws an exception.
111
112       hostname() doesn't accept any arguments
113
114       The function "hostname()" in the Sys::Hostname module has always been
115       documented to be called with no arguments.  Historically it has not
116       enforced this, and has actually accepted and ignored any arguments.  As
117       a result, some users have got the mistaken impression that an argument
118       does something useful.  To avoid these bugs, the function is being made
119       strict.  Passing arguments was deprecated in Perl 5.28 and became fatal
120       in Perl 5.32.
121
122       Unescaped left braces in regular expressions
123
124       The simple rule to remember, if you want to match a literal "{"
125       character (U+007B "LEFT CURLY BRACKET") in a regular expression
126       pattern, is to escape each literal instance of it in some way.
127       Generally easiest is to precede it with a backslash, like "\{" or
128       enclose it in square brackets ("[{]").  If the pattern delimiters are
129       also braces, any matching right brace ("}") should also be escaped to
130       avoid confusing the parser, for example,
131
132        qr{abc\{def\}ghi}
133
134       Forcing literal "{" characters to be escaped will enable the Perl
135       language to be extended in various ways in future releases.  To avoid
136       needlessly breaking existing code, the restriction is not enforced in
137       contexts where there are unlikely to ever be extensions that could
138       conflict with the use there of "{" as a literal.  A non-deprecation
139       warning that the left brace is being taken literally is raised in
140       contexts where there could be confusion about it.
141
142       Literal uses of "{" were deprecated in Perl 5.20, and some uses of it
143       started to give deprecation warnings since. These cases were made fatal
144       in Perl 5.26. Due to an oversight, not all cases of a use of a literal
145       "{" got a deprecation warning.  Some cases started warning in Perl
146       5.26, and were made fatal in Perl 5.30.  Other cases started in Perl
147       5.28, and were made fatal in 5.32.
148
149       In XS code, use of various macros dealing with UTF-8.
150
151       The macros below now require an extra parameter than in versions prior
152       to Perl 5.32.  The final parameter in each one is a pointer into the
153       string supplied by the first parameter beyond which the input will not
154       be read.  This prevents potential reading beyond the end of the buffer.
155       "isALPHANUMERIC_utf8", "isASCII_utf8", "isBLANK_utf8", "isCNTRL_utf8",
156       "isDIGIT_utf8", "isIDFIRST_utf8", "isPSXSPC_utf8", "isSPACE_utf8",
157       "isVERTWS_utf8", "isWORDCHAR_utf8", "isXDIGIT_utf8",
158       "isALPHANUMERIC_LC_utf8", "isALPHA_LC_utf8", "isASCII_LC_utf8",
159       "isBLANK_LC_utf8", "isCNTRL_LC_utf8", "isDIGIT_LC_utf8",
160       "isGRAPH_LC_utf8", "isIDCONT_LC_utf8", "isIDFIRST_LC_utf8",
161       "isLOWER_LC_utf8", "isPRINT_LC_utf8", "isPSXSPC_LC_utf8",
162       "isPUNCT_LC_utf8", "isSPACE_LC_utf8", "isUPPER_LC_utf8",
163       "isWORDCHAR_LC_utf8", "isXDIGIT_LC_utf8", "toFOLD_utf8",
164       "toLOWER_utf8", "toTITLE_utf8", and "toUPPER_utf8".
165
166       Since Perl 5.26, this functionality with the extra parameter has been
167       available by using a corresponding macro to each one of these, and
168       whose name is formed by appending "_safe" to the base name.  There is
169       no change to the functionality of those.  For example,
170       "isDIGIT_utf8_safe" corresponds to "isDIGIT_utf8", and both now behave
171       identically.  All are documented in "Character case changing" in
172       perlapi and "Character classification" in perlapi.
173
174       This change was originally scheduled for 5.30, but was delayed until
175       5.32.
176
177       "File::Glob::glob()" was removed
178
179       "File::Glob" has a function called "glob", which just calls "bsd_glob".
180
181       "File::Glob::glob()" was deprecated in Perl 5.8. A deprecation message
182       was issued from Perl 5.26 onwards, the function became fatal in Perl
183       5.30, and was removed entirely in Perl 5.32.
184
185       Code using "File::Glob::glob()" should call "File::Glob::bsd_glob()"
186       instead.
187
188   Perl 5.30
189       $* is no longer supported
190
191       Before Perl 5.10, setting $* to a true value globally enabled multi-
192       line matching within a string. This relique from the past lost its
193       special meaning in 5.10. Use of this variable became a fatal error in
194       Perl 5.30, freeing the variable up for a future special meaning.
195
196       To enable multiline matching one should use the "/m" regexp modifier
197       (possibly in combination with "/s"). This can be set on a per match
198       bases, or can be enabled per lexical scope (including a whole file)
199       with "use re '/m'".
200
201       $# is no longer supported
202
203       This variable used to have a special meaning -- it could be used to
204       control how numbers were formatted when printed. This seldom used
205       functionality was removed in Perl 5.10. In order to free up the
206       variable for a future special meaning, its use became a fatal error in
207       Perl 5.30.
208
209       To specify how numbers are formatted when printed, one is advised to
210       use "printf" or "sprintf" instead.
211
212       Assigning non-zero to $[ is fatal
213
214       This variable (and the corresponding "array_base" feature and arybase
215       module) allowed changing the base for array and string indexing
216       operations.
217
218       Setting this to a non-zero value has been deprecated since Perl 5.12
219       and throws a fatal error as of Perl 5.30.
220
221       "File::Glob::glob()" will disappear
222
223       "File::Glob" has a function called "glob", which just calls "bsd_glob".
224       However, its prototype is different from the prototype of "CORE::glob",
225       and hence, "File::Glob::glob" should not be used.
226
227       "File::Glob::glob()" was deprecated in Perl 5.8. A deprecation message
228       was issued from Perl 5.26 onwards, and in Perl 5.30 this was turned
229       into a fatal error.
230
231       Code using "File::Glob::glob()" should call "File::Glob::bsd_glob()"
232       instead.
233
234       Unescaped left braces in regular expressions (for 5.30)
235
236       See "Unescaped left braces in regular expressions" above.
237
238       Unqualified "dump()"
239
240       Use of "dump()" instead of "CORE::dump()" was deprecated in Perl 5.8,
241       and an unqualified "dump()" is no longer available as of Perl 5.30.
242
243       See "dump" in perlfunc.
244
245       Using my() in false conditional.
246
247       There has been a long-standing bug in Perl that causes a lexical
248       variable not to be cleared at scope exit when its declaration includes
249       a false conditional.  Some people have exploited this bug to achieve a
250       kind of static variable.  To allow us to fix this bug, people should
251       not be relying on this behavior.
252
253       Instead, it's recommended one uses "state" variables to achieve the
254       same effect:
255
256           use 5.10.0;
257           sub count {state $counter; return ++ $counter}
258           say count ();    # Prints 1
259           say count ();    # Prints 2
260
261       "state" variables were introduced in Perl 5.10.
262
263       Alternatively, you can achieve a similar static effect by declaring the
264       variable in a separate block outside the function, e.g.,
265
266           sub f { my $x if 0; return $x++ }
267
268       becomes
269
270           { my $x; sub f { return $x++ } }
271
272       The use of "my()" in a false conditional has been deprecated in Perl
273       5.10, and became a fatal error in Perl 5.30.
274
275       Reading/writing bytes from/to :utf8 handles.
276
277       The sysread(), recv(), syswrite() and send() operators are deprecated
278       on handles that have the ":utf8" layer, either explicitly, or
279       implicitly, eg., with the ":encoding(UTF-16LE)" layer.
280
281       Both sysread() and recv() currently use only the ":utf8" flag for the
282       stream, ignoring the actual layers.  Since sysread() and recv() do no
283       UTF-8 validation they can end up creating invalidly encoded scalars.
284
285       Similarly, syswrite() and send() use only the ":utf8" flag, otherwise
286       ignoring any layers.  If the flag is set, both write the value UTF-8
287       encoded, even if the layer is some different encoding, such as the
288       example above.
289
290       Ideally, all of these operators would completely ignore the ":utf8"
291       state, working only with bytes, but this would result in silently
292       breaking existing code.  To avoid this a future version of perl will
293       throw an exception when any of sysread(), recv(), syswrite() or send()
294       are called on handle with the ":utf8" layer.
295
296       As of Perl 5.30, it is no longer be possible to use sysread(), recv(),
297       syswrite() or send() to read or send bytes from/to :utf8 handles.
298
299       Use of unassigned code point or non-standalone grapheme for a
300       delimiter.
301
302       A grapheme is what appears to a native-speaker of a language to be a
303       character.  In Unicode (and hence Perl) a grapheme may actually be
304       several adjacent characters that together form a complete grapheme.
305       For example, there can be a base character, like "R" and an accent,
306       like a circumflex "^", that appear to be a single character when
307       displayed, with the circumflex hovering over the "R".
308
309       As of Perl 5.30, use of delimiters which are non-standalone graphemes
310       is fatal, in order to move the language to be able to accept multi-
311       character graphemes as delimiters.
312
313       Also, as of Perl 5.30, delimiters which are unassigned code points but
314       that may someday become assigned are prohibited.  Otherwise, code that
315       works today would fail to compile if the currently unassigned delimiter
316       ends up being something that isn't a stand-alone grapheme.  Because
317       Unicode is never going to assign non-character code points, nor code
318       points that are above the legal Unicode maximum, those can be
319       delimiters.
320
321   Perl 5.28
322       Attributes ":locked" and ":unique"
323
324       The attributes ":locked" (on code references) and ":unique" (on array,
325       hash and scalar references) have had no effect since Perl 5.005 and
326       Perl 5.8.8 respectively. Their use has been deprecated since.
327
328       As of Perl 5.28, these attributes are syntax errors. Since the
329       attributes do not do anything, removing them from your code fixes the
330       syntax error; and removing them will not influence the behaviour of
331       your code.
332
333       Bare here-document terminators
334
335       Perl has allowed you to use a bare here-document terminator to have the
336       here-document end at the first empty line. This practise was deprecated
337       in Perl 5.000; as of Perl 5.28, using a bare here-document terminator
338       throws a fatal error.
339
340       You are encouraged to use the explicitly quoted form if you wish to use
341       an empty line as the terminator of the here-document:
342
343         print <<"";
344           Print this line.
345
346         # Previous blank line ends the here-document.
347
348       Setting $/ to a reference to a non-positive integer
349
350       You assigned a reference to a scalar to $/ where the referenced item is
351       not a positive integer.  In older perls this appeared to work the same
352       as setting it to "undef" but was in fact internally different, less
353       efficient and with very bad luck could have resulted in your file being
354       split by a stringified form of the reference.
355
356       In Perl 5.20.0 this was changed so that it would be exactly the same as
357       setting $/ to undef, with the exception that this warning would be
358       thrown.
359
360       As of Perl 5.28, setting $/ to a reference of a non-positive integer
361       throws a fatal error.
362
363       You are recommended to change your code to set $/ to "undef" explicitly
364       if you wish to slurp the file.
365
366       Limit on the value of Unicode code points.
367
368       Unicode only allows code points up to 0x10FFFF, but Perl allows much
369       larger ones. Up till Perl 5.28, it was allowed to use code points
370       exceeding the maximum value of an integer ("IV_MAX").  However, that
371       did break the perl interpreter in some constructs, including causing it
372       to hang in a few cases.  The known problem areas were in "tr///",
373       regular expression pattern matching using quantifiers, as quote
374       delimiters in "qX...X" (where X is the "chr()" of a large code point),
375       and as the upper limits in loops.
376
377       The use of out of range code points was deprecated in Perl 5.24; as of
378       Perl 5.28 using a code point exceeding "IV_MAX" throws a fatal error.
379
380       If your code is to run on various platforms, keep in mind that the
381       upper limit depends on the platform. It is much larger on 64-bit word
382       sizes than 32-bit ones. For 32-bit integers, "IV_MAX" equals
383       0x7FFFFFFF, for 64-bit integers, "IV_MAX" equals 0x7FFFFFFFFFFFFFFF.
384
385       Use of comma-less variable list in formats.
386
387       It was allowed to use a list of variables in a format, without
388       separating them with commas. This usage has been deprecated for a long
389       time, and as of Perl 5.28, this throws a fatal error.
390
391       Use of "\N{}"
392
393       Use of "\N{}" with nothing between the braces was deprecated in Perl
394       5.24, and throws a fatal error as of Perl 5.28.
395
396       Since such a construct is equivalent to using an empty string, you are
397       recommended to remove such "\N{}" constructs.
398
399       Using the same symbol to open a filehandle and a dirhandle
400
401       It used to be legal to use "open()" to associate both a filehandle and
402       a dirhandle to the same symbol (glob or scalar).  This idiom is likely
403       to be confusing, and it was deprecated in Perl 5.10.
404
405       Using the same symbol to "open()" a filehandle and a dirhandle throws a
406       fatal error as of Perl 5.28.
407
408       You should be using two different symbols instead.
409
410       ${^ENCODING} is no longer supported.
411
412       The special variable "${^ENCODING}" was used to implement the
413       "encoding" pragma. Setting this variable to anything other than "undef"
414       was deprecated in Perl 5.22. Full deprecation of the variable happened
415       in Perl 5.25.3.
416
417       Setting this variable to anything other than an undefined value throws
418       a fatal error as of Perl 5.28.
419
420       "B::OP::terse"
421
422       This method, which just calls "B::Concise::b_terse", has been
423       deprecated, and disappeared in Perl 5.28. Please use "B::Concise"
424       instead.
425
426       Use of inherited AUTOLOAD for non-method %s::%s() is no longer allowed
427
428       As an (ahem) accidental feature, "AUTOLOAD" subroutines were looked up
429       as methods (using the @ISA hierarchy) even when the subroutines to be
430       autoloaded were called as plain functions (e.g. "Foo::bar()"), not as
431       methods (e.g. "Foo->bar()" or "$obj->bar()").
432
433       This bug was deprecated in Perl 5.004, has been rectified in Perl 5.28
434       by using method lookup only for methods' "AUTOLOAD"s.
435
436       The simple rule is:  Inheritance will not work when autoloading non-
437       methods.  The simple fix for old code is:  In any module that used to
438       depend on inheriting "AUTOLOAD" for non-methods from a base class named
439       "BaseClass", execute "*AUTOLOAD = \&BaseClass::AUTOLOAD" during
440       startup.
441
442       In code that currently says "use AutoLoader; @ISA = qw(AutoLoader);"
443       you should remove AutoLoader from @ISA and change "use AutoLoader;" to
444       "use AutoLoader 'AUTOLOAD';".
445
446       Use of code points over 0xFF in string bitwise operators
447
448       The string bitwise operators, "&", "|", "^", and "~", treat their
449       operands as strings of bytes. As such, values above 0xFF are
450       nonsensical. Using such code points with these operators was deprecated
451       in Perl 5.24, and is fatal as of Perl 5.28.
452
453       In XS code, use of "to_utf8_case()"
454
455       This function has been removed as of Perl 5.28; instead convert to call
456       the appropriate one of: "toFOLD_utf8_safe".  "toLOWER_utf8_safe",
457       "toTITLE_utf8_safe", or "toUPPER_utf8_safe".
458
459   Perl 5.26
460       "--libpods" in "Pod::Html"
461
462       Since Perl 5.18, the option "--libpods" has been deprecated, and using
463       this option did not do anything other than producing a warning.
464
465       The "--libpods" option is no longer recognized as of Perl 5.26.
466
467       The utilities "c2ph" and "pstruct"
468
469       These old, perl3-era utilities have been deprecated in favour of "h2xs"
470       for a long time. As of Perl 5.26, they have been removed.
471
472       Trapping "$SIG {__DIE__}" other than during program exit.
473
474       The $SIG{__DIE__} hook is called even inside an "eval()". It was never
475       intended to happen this way, but an implementation glitch made this
476       possible. This used to be deprecated, as it allowed strange action at a
477       distance like rewriting a pending exception in $@. Plans to rectify
478       this have been scrapped, as users found that rewriting a pending
479       exception is actually a useful feature, and not a bug.
480
481       Perl never issued a deprecation warning for this; the deprecation was
482       by documentation policy only. But this deprecation has been lifted as
483       of Perl 5.26.
484
485       Malformed UTF-8 string in "%s"
486
487       This message indicates a bug either in the Perl core or in XS code.
488       Such code was trying to find out if a character, allegedly stored
489       internally encoded as UTF-8, was of a given type, such as being
490       punctuation or a digit.  But the character was not encoded in legal
491       UTF-8.  The %s is replaced by a string that can be used by
492       knowledgeable people to determine what the type being checked against
493       was.
494
495       Passing malformed strings was deprecated in Perl 5.18, and became fatal
496       in Perl 5.26.
497
498   Perl 5.24
499       Use of *glob{FILEHANDLE}
500
501       The use of *glob{FILEHANDLE} was deprecated in Perl 5.8.  The intention
502       was to use *glob{IO} instead, for which *glob{FILEHANDLE} is an alias.
503
504       However, this feature was undeprecated in Perl 5.24.
505
506       Calling POSIX::%s() is deprecated
507
508       The following functions in the "POSIX" module are no longer available:
509       "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower",
510       "isprint", "ispunct", "isspace", "isupper", and "isxdigit".  The
511       functions are buggy and don't work on UTF-8 encoded strings.  See their
512       entries in POSIX for more information.
513
514       The functions were deprecated in Perl 5.20, and removed in Perl 5.24.
515
516   Perl 5.16
517       Use of %s on a handle without * is deprecated
518
519       It used to be possible to use "tie", "tied" or "untie" on a scalar
520       while the scalar holds a typeglob. This caused its filehandle to be
521       tied. It left no way to tie the scalar itself when it held a typeglob,
522       and no way to untie a scalar that had had a typeglob assigned to it.
523
524       This was deprecated in Perl 5.14, and the bug was fixed in Perl 5.16.
525
526       So now "tie $scalar" will always tie the scalar, not the handle it
527       holds.  To tie the handle, use "tie *$scalar" (with an explicit
528       asterisk).  The same applies to "tied *$scalar" and "untie *$scalar".
529

SEE ALSO

531       warnings, diagnostics.
532
533
534
535perl v5.36.3                      2023-11-30                PERLDEPRECATION(1)
Impressum