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

SEE ALSO

435       warnings, diagnostics.
436
437
438
439perl v5.26.3                      2018-03-23                PERLDEPRECATION(1)
Impressum