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

SEE ALSO

500       warnings, diagnostics.
501
502
503
504perl v5.32.1                      2021-03-31                PERLDEPRECATION(1)
Impressum