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

SEE ALSO

599       warnings, diagnostics.
600
601
602
603perl v5.38.2                      2023-11-30                PERLDEPRECATION(1)
Impressum