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

SEE ALSO

485       warnings, diagnostics.
486
487
488
489perl v5.28.2                      2018-11-01                PERLDEPRECATION(1)
Impressum