blib/lib/Syntax/Construct.pm

filter: Statementstmt 88.8% 64 / 72 Branchbran 75.0% 27 / 36 Conditioncond 70.5% 12 / 17 MC/DCmcdc 44.4% 4 / 9 Subroutinesub 93.3% 14 / 15 Podpod 100% 2 / 2 totaltotal 81.4% 123 / 151 CC 27 SCAR 20.3
CC
27
Cov
82%
import
15.3
_is_old_empty
6.0
__ANON__
4.8
CRAP 7.6
↑ Summary
1 package Syntax::Construct;
2  
3 7 ▶use 5.006002;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 our $VERSION = '1.046';
8  
9 7 ▶my %introduces = do { no warnings 'qw';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ( '5.044' => [qw[
11 named-params multi-for-ref unicode17.0
12 ]],
13 '5.042' => [qw[
14 :writer my_method ->& unicode16.0 ^^=
15 ]],
16 '5.040' => [qw[
17 ^^ __CLASS__ :reader
18 ]],
19 '5.038' => [qw[
20 unicode15.0 ^HOOK signature-default-operator
21 INCDIR *{} REG_INF_I32_MAX
22 ^LAST_SUCCESSFUL_PATTERN
23 ]],
24 '5.036' => [qw[
25 unicode14.0
26 ]],
27 '5.034' => [qw[
28 {,n} 0o blanks-in-curlies
29 ]],
30 '5.032' => [qw[
31 unicode13.0 chained-comparisons
32 unicode-identifier-status
33 unicode-name-property
34 ]],
35 '5.030' => [qw[
36 unicode12.1 uniprop_wildcards qr'N
37 turkic-casing ^RE_COMPILE_RECURSION_LIMIT
38 ]],
39 '5.028' => [qw[
40 delete% unicode10.0 state@=
41 ]],
42 '5.026' => [qw[
43 <<~ /xx ^CAPTURE unicode9.0 unicode-scx scalar%
44 ]],
45 '5.024' => [qw[
46 unicode8.0 \b{lb} sprintf-reorder
47 ]],
48 '5.022' => [qw[
49 <<>> \b{} /n unicode7.0 attr-const
50 fileno-dir ()x= hexfloat chr-inf
51 empty-slice /x-unicode
52 ]],
53 '5.020' => [qw[
54 attr-prototype drand48 %slice
55 unicode6.3 \p{Unicode} utf8-locale
56 s-utf8-delimiters
57 ]],
58 '5.018' => [qw[
59 computed-labels while-each method-on-any-string
60 split-space
61 ]],
62 '5.016' => [qw[
63 charnames __FILE__()
64 ]],
65 '5.014' => [qw[
66 ?^ /r /d /l /u /a auto-deref
67 ^GLOBAL_PHASE \o package-block
68 srand-return prototype+ sig-warn-obj
69 ]],
70 '5.012' => [qw[
71 package-version ... each-array
72 keys-array values-array delete-local
73 length-undef \N while-readdir
74 ]],
75 '5.010' => [qw[
76 // ?PARNO ?<> ?| quant+ regex-verbs
77 \K \R \v \h \gN readline()
78 stack-file-test recursive-sort /p
79 lexical-$_ pack<
80 ]],
81 '5.008001' => [qw[
82 s-utf8-delimiters-hack
83 ]],
84 old => [qw[
85 ?? for-qw @_=split no-sigil
86 ]],
87 )};
88  
89 7 my %removed = ( 'auto-deref' => '5.024',
90 'lexical-$_' => '5.024',
91 '??' => '5.022',
92 'no-sigil' => '5.022',
93 's-utf8-delimiters-hack' => '5.020',
94 'for-qw' => '5.018',
95 '@_=split' => '5.012',
96 );
97  
98 7 my %alias = (
99 # old
100 'split-populates-@_' => '@_=split',
101 # 5.010
102 '\H' => '\h',
103 '\V' => '\v',
104 'defined-or' => '//',
105 'lexical-default-variable' => 'lexical-$_',
106 'pack-byte-order-modifiers' => 'pack<',
107 'readline-argv' => 'readline()',
108 'regex-generic-linebreak' => '\R',
109 'regex-horizontal-whitespace' => '\h',
110 'regex-keep-left' => '\K',
111 'regex-named-capture-group' => '?<>',
112 'regex-possessive-quantifier' => 'quant+',
113 'regex-possessive-match' => 'quant+',
114 'regex-preserve-match-captures' => '/p',
115 'regex-recursive-subpattern' => '?PARNO',
116 'regex-relative-backreference' => '\gN',
117 'regex-reset-branch' => '?|',
118 'regex-vertical-whitespace' => '\v',
119 # 5.012
120 'statement-ellipsis' => '...',
121 'yada-yada' => '...',
122 'triple-dot' => '...',
123 'regex-non-newline' => '\N',
124 # 5.014
125 'non-destructive-subst' => '/r',
126 'non-destructive-substitution' => '/r',
127 'regex-restrict-ascii-range' => '/a',
128 'regex-unicode-strings' => '/u',
129 'regex-use-default-modifiers' => '?^',
130 'regex-compile-as-default' => '/d',
131 'regex-compile-as-locale' => '/l',
132 'regex-compile-as-unicode-strings' => '/u',
133 'global-phase' => '^GLOBAL_PHASE',
134 'octal-escape' => '\o',
135 # 5.016
136 '__LINE__()' => '__FILE__()',
137 '__PACKAGE__()' => '__FILE__()',
138 # 5.020
139 'hash-slice' => '%slice',
140 'attribute-prototype' => 'attr-prototype',
141 'regex-property-unicode' => '\p{Unicode}',
142 'wide-char-delimiters' => 's-utf8-delimiters',
143 'unicode-6.3' => 'unicode6.3',
144 # 5.022
145 'double-diamond' => '<<>>',
146 'operator-double-diamond' => '<<>>',
147 'regex-non-capturing' => '/n',
148 '\b{gcb}' => '\b{}',
149 '\b{wb}' => '\b{}',
150 '\b{sb}' => '\b{}',
151 'regex-unicode-boundary' => '\b{}',
152 'regex-unicode-grapheme-cluster-boundary' => '\b{}',
153 'regex-unicode-word-boundary' => '\b{}',
154 'regex-unicode-sentence-boundary' => '\b{}',
155 'attribute-const' => 'attr-const',
156 'list-repetition-assignment' => '()x=',
157 'hexadecimal-floating-numbers' => 'hexfloat',
158 'pack-inf' => 'chr-inf',
159 'regex-x-unicode' => '/x-unicode',
160 'regex-x-handles-unicode' => '/x-unicode',
161 'unicode-7.0' => 'unicode7.0',
162 # 5.024
163 'unicode-8.0' => 'unicode8.0',
164 'regex-unicode-line-break-boundary' => '\b{lb}',
165 'printf-precision-argument-reorder' => 'sprintf-reorder',
166 'sprintf-precision-argument-reorder' => 'sprintf-reorder',
167 # 5.026
168 'unicode-9.0' => 'unicode9.0',
169 'heredoc-indent' => '<<~',
170 'regex-xx' => '/xx',
171 'capture-variable' => '^CAPTURE',
172 'scalar-hash' => 'scalar%',
173 # 5.028
174 'hash-delete-slice' => 'delete%',
175 'unicode-10.0' => 'unicode10.0',
176 'state-array' => 'state@=',
177 'state-hash' => 'state@=',
178 'list-context-state' => 'state@=',
179 # 5.030
180 'named-char-in-single-quoted-regex' => "qr'N",
181 'unicode-12.1' => 'unicode12.1',
182 're-compile-recursion-limit' => '^RE_COMPILE_RECURSION_LIMIT',
183 # 5.032
184 'unicode-13.0' => 'unicode13.0',
185 'unicode-identifier-type' => 'unicode-identifier-status',
186 # 5.034
187 'empty-left-quantifier' => '{,n}',
188 'octal-literals' => '0o',
189 # 5.038
190 'keyword-hook' => '^HOOK',
191 'optimistic-eval' => '*{}',
192 # 5.040
193 'logical-xor' => '^^',
194 # 5.042
195 'lexical-method-invocation-operator' => '->&',
196 'assign-logical-xor' => '^^=',
197 );
198  
199 my %_introduced = map {
200 7 my $version = $_;
201 140 map { $_ => $version } @{ $introduces{$version} }
202 } keys %introduces;
203  
204 7 my %introduced = %_introduced;
205 7 delete @introduced{ @{ $introduces{old} } };
206  
207 109 ▶sub _hook {
Subroutine _hook: called CC=1 SCAR=0.4
208 1 ▶ { drand48 => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
209 1 require Config;
210 warn "Unknown rand implementation at ", _position(1), ".\n"
211 1 ▶ unless 'Perl_drand48' eq $Config::Config{randfunc};
Branch: 1 branch
BranchTrueFalseTotal
unless "Perl_drand48" eq $Config::Config{"randfunc"} 0 1 1
212 },
213 1 ▶ 'turkic-casing' => sub {
Subroutine __ANON__: called CC=4 SCAR=15.8
214 1 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { BEGIN { $^H{'locale'} = '0'; } require POSIX; my $orig_locale = POSIX::setlocale(POSIX::LC_CTYPE()); (POSIX::setlocale(POSIX::LC_CTYPE(), "tr_TR.UTF-8") || "") eq "tr_TR.UTF-8" or die; my $cmp = lc "I" ne "i"; POSIX::setlocale(POSIX::LC_CTYPE(), $orig_locale); $cmp } } or die 'Turkic locale casing not working at ' . _position(1) . ".\n" 0 1 1
215 7 ▶ use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
216 1 require POSIX;
217 1 my $orig_locale = POSIX::setlocale(POSIX::LC_CTYPE());
218 1 ▶ (POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8') || "")
Branch: 1 branch
BranchTrueFalseTotal
(POSIX::setlocale(POSIX::LC_CTYPE(), "tr_TR.UTF-8") || "") eq "tr_TR.UTF-8" or die 0 1 1
Condition50%1/2
POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8') || ''
l!l
01
MC/DC0%0/1
POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8') || ''
POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8')
Truth table50%1/2
A
A= POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8')
Aresult
11
00
219 eq 'tr_TR.UTF-8' or die;
220 0 my $cmp = lc 'I' ne 'i';
221 0 POSIX::setlocale(POSIX::LC_CTYPE(), $orig_locale);
222 0 $cmp
223 } or die 'Turkic locale casing not working at '
224 . _position(1) . "\.\n";
225 },
226 }
227 109 }
228  
229  
230 108 ▶sub removed {
Subroutine removed: called CC=4 SCAR=13.9
Pod documented
231 108 my $construct = shift;
232 return $construct
233 ? $removed{$construct}
234 108 ▶ || $alias{$construct} && $removed{ $alias{$construct} }
Branch: 1 branch
BranchTrueFalseTotal
$construct ? : 107 1 108
Condition83%5/6
$removed{$construct} or $alias{$construct} and $removed{$alias{$construct}}
l!l&&r!l&&!r
51101
$alias{$construct} and $removed{$alias{$construct}}
!ll&&!rl&&r
10101
MC/DC66%2/3
$removed{$construct} or $alias{$construct} and $removed{$alias{$construct}}
$removed{$construct} $alias{$construct} $removed{$alias{$construct}}
Truth table75%3/4
A or B and C
A= $removed{$construct}B= $alias{$construct}C= $removed{$alias{$construct}}
ABCresult
1XX1
0111
00X0
0100
235 : keys %removed
236 }
237  
238  
239 5 ▶sub introduced {
Subroutine introduced: called CC=4 SCAR=13.9
Pod documented
240 5 my $construct = shift;
241 return $construct
242 ? $introduced{$construct}
243 5 ▶ || $alias{$construct} && $introduced{ $alias{$construct} }
Branch: 1 branch
BranchTrueFalseTotal
$construct ? : 4 1 5
Condition83%5/6
$introduced{$construct} or $alias{$construct} and $introduced{$alias{$construct}}
l!l&&r!l&&!r
211
$alias{$construct} and $introduced{$alias{$construct}}
!ll&&!rl&&r
101
MC/DC66%2/3
$introduced{$construct} or $alias{$construct} and $introduced{$alias{$construct}}
$introduced{$construct} $alias{$construct} $introduced{$alias{$construct}}
Truth table75%3/4
A or B and C
A= $introduced{$construct}B= $alias{$construct}C= $introduced{$alias{$construct}}
ABCresult
1XX1
0111
00X0
0100
244 : keys %introduced
245 }
246  
247  
248 11 ▶sub _position {
Subroutine _position: called CC=1 SCAR=0.0
249 11 join ' line ', (caller(1 + !! shift))[1,2]
250 }
251  
252  
253 112 ▶sub import {
Subroutine import: called CC=15 SCAR=27.3
254 112 shift;
255 112 my $min_version = 0;
256 112 my $max_version = 6;
257 112 my ($constr, $d_constr);
258 112 my @actions;
259 112 for my $name (@_) {
260 111 ▶ local $_ = exists $alias{$name} ? $alias{$name} : $name;
Branch: 1 branch
BranchTrueFalseTotal
exists $alias{$name} ? : 1 110 111
261 111 ▶ if ($introduced{$_}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($introduced{$_}) { } 106 5 111
elsif (not $removed{$_}) { } 1 4 5
262 ($min_version, $constr) = ($introduced{$_}, $name)
263 106 ▶ if $introduced{$_} gt $min_version;
Branch: 1 branch
BranchTrueFalseTotal
if $introduced{$_} gt $min_version 106 0 106
264 } elsif (! $removed{$_}) {
265 1 die "Unknown construct `$name' at ",
266 _position(),
267 ". Try upgrading Syntax::Construct first.\n"
268 }
269  
270 110 ▶ if ($removed{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($removed{$_}) 7 103 110
271 ($max_version, $d_constr) = ($removed{$_}, $name)
272 7 ▶ if $removed{$_} lt $max_version;
Branch: 1 branch
BranchTrueFalseTotal
if $removed{$_} lt $max_version 7 0 7
273 }
274  
275 110 my $action = _hook()->{$_};
276 110 ▶ push @actions, $action if $action;
Branch: 1 branch
BranchTrueFalseTotal
if $action 3 107 110
277 }
278 111 ▶ die 'Empty construct list at ', _position(), ".\n" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 110 111
279  
280 110 my $nearest_stable = _nearest_stable();
281 110 ▶ if ($max_version le $nearest_stable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_version le $nearest_stable) 7 103 110
282 7 ▶ warn "Faking version $nearest_stable to test removed constructs.\n"
Branch: 1 branch
BranchTrueFalseTotal
if not _is_stable($]) and $max_version eq $nearest_stable 0 7 7
Condition33%1/3
not _is_stable($]) and $max_version eq $nearest_stable
!ll&&!rl&&r
700
MC/DC0%0/2
not _is_stable($]) and $max_version eq $nearest_stable
not _is_stable($]) $max_version eq $nearest_stable
Truth table33%1/3
not(A) and B
A= not _is_stable($])B= $max_version eq $nearest_stable
ABresult
0X0
100
111
283 if ! _is_stable($]) && $max_version eq $nearest_stable;
284 7 die "$d_constr removed in $max_version at ", _position(), ".\n";
285 }
286  
287 103 ▶ die "Unsupported construct $constr at ", _position(),
Branch: 1 branch
BranchTrueFalseTotal
unless $min_version le $] 1 102 103
288 sprintf " (Perl %s needed)\n", $min_version
289 unless $min_version le $];
290  
291 102 $_->() for @actions;
292 }
293  
294  
295 136 ▶sub _is_stable {
Subroutine _is_stable: called CC=1 SCAR=0.0
296 136 my ($version) = @_;
297 136 return $version =~ /^[0-5]\.[0-9][0-9][02468]/
298 }
299  
300 110 ▶sub _nearest_stable {
Subroutine _nearest_stable: called CC=2 SCAR=11.6
301 110 ▶ return $] if _is_stable($]);
Branch: 1 branch
BranchTrueFalseTotal
if _is_stable($]) 110 0 110
302 0 my ($major, $minor) = $] =~ /^([0-5])\.([0-9][0-9][13579])/;
303 0 ++$minor;
304 0 return "$major.$minor"
305 }
306  
307  
308 0 ▶sub _is_old_empty { @{ $introduces{old} } ? 0 : 1 }
Subroutine _is_old_empty: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
@{$introduces{'old'};} ? : 0 0 0
309  
310  
311 =head1 NAME
312  
313 Syntax::Construct - Explicitly state which non-feature constructs are used in the code.
314  
315 =head1 VERSION
316  
317 Version 1.046
318  
319 =head1 SYNOPSIS
320  
321 For some new syntactic constructs, there is the L<feature> pragma. For
322 the rest, there is B<Syntax::Construct>.
323  
324 use Syntax::Construct qw( // ... /r );
325  
326 my $x = shift // 'default';
327 my $y = $x =~ s/de(fault)/$1/r;
328 if ($y =~ /^fault/) {
329 ...
330 }
331  
332 There are two subroutines (not exported) which you can use to query
333 the lists of constructs programmatically: C<introduced> and
334 C<removed> (see below).
335  
336 my @constructs = Syntax::Construct::introduced();
337 say "$_ was introduced in ",
338 Syntax::Construct::introduced($_) for @constructs;
339  
340 =head1 DESCRIPTION
341  
342 This module provides a simple way of specifying syntactic constructs
343 that are not implemented via the L<feature> pragma, but are still not
344 compatible with older versions of Perl.
345  
346 It's the programmer's responsibility to track the constructs and list
347 them (but see L<Perl::MinimumVersion> on how to extract the
348 information from existing code).
349  
350 Using C<use Syntax::Construct qw( // );> doesn't really change
351 anything if you're running Perl 5.010+, but it gives much better error
352 messages in older versions:
353  
354 Unsupported construct //
355  
356 instead of
357  
358 Search pattern not terminated
359  
360 Three groups of people can benefit from the module:
361  
362 =over 4
363  
364 =item 1.
365  
366 The authors of the module using L<Syntax::Construct> win, as they have
367 all the constructs in one place (i.e. L<Syntax::Construct>'s
368 documentation) and they don't waste their time searching through
369 perldeltas and other places.
370  
371 =item 2.
372  
373 Users of their modules win as they get meaningful error messages
374 telling them which Perl version they need to upgrade to.
375  
376 =item 3.
377  
378 The programmer they hired to work around the problem wins as they know
379 what constructs to replace in the code to make it run in the ancient
380 version.
381  
382 =back
383  
384 =head2 Good Practice
385  
386 Some programmers just use all the I<non-features> their current Perl
387 version provides without any notice. This leads to weird error
388 messages in older Perl versions.
389  
390 Some other programmers will place C<use 5.022;> towards the top of the
391 script, even if the only I<non-feature> they use is the C<//> operator
392 available in 5.010 already. This prevents users of older versions of
393 Perl to run the script, even if it would otherwise be easily possible.
394  
395 The kindest programmers will add C<use 5.010; # //> towards the top of
396 the script. But it means they have to remember or find out what
397 version introduced the I<non-feature> they use.
398  
399 B<Syntax::Construct> liberates you from the need to remember all the
400 I<non-features> together with Perl versions that introduced them. It
401 makes it easier for users of older Perl versions to migrate your code
402 to their system. And finally, it improves the error messages they get.
403  
404 Similarly, it's a good practice to keep specifying C<use feature qw{
405 postderef };> even if it's a no-op since 5.024: it makes your script
406 available for people running older Perl versions. The same applies to
407 C<use charnames> in 5.016 and later, etc.
408  
409 =head1 EXPORT
410  
411 Nothing. Using B<Syntax::Construct> with no parameters is an error,
412 giving it an empty list is a no-op (but you can then access the
413 C<introduced> and C<removed> subroutines).
414  
415 =over 4
416  
417 =item introduced
418  
419 Without arguments, returns a list of all the supported
420 constructs. With an argument, returns the version in which the given
421 construct was introduced.
422  
423 =item removed
424  
425 Same as C<introduced>, but for removed constructs (e.g. auto-deref in
426 5.024).
427  
428 =back
429  
430 =head1 RECOGNISED CONSTRUCTS
431  
432 =head2 5.008001
433  
434 =head3 s-utf8-delimiters-hack
435  
436 See L</s-utf8-delimiters>. The hack doesn't seem to work in 5.008
437 and older. Removed in 5.020.
438  
439 =head2 5.010
440  
441 =head3 recursive-sort
442  
443 L<perl5100delta/Recursive sort subs>.
444  
445 =head3 //
446  
447 L<perl5100delta/Defined-or operator> or L<perlop/Logical Defined-Or>.
448  
449 Alias: defined-or
450  
451 =head3 ?PARNO
452  
453 "Recursive Patterns" under L<perl5100delta/Regular expressions> or
454 L<perlre/"(?PARNO) (?-PARNO) (?+PARNO) (?R) (?0)">.
455  
456 Alias: regex-recursive-subpattern
457  
458 =head3 ?<>
459  
460 "Named Capture Buffers" under L<perl5100delta/Regular expressions> or
461 L<perlre/"(?E<60>NAMEE<62>pattern)">.
462  
463 Alias: regex-named-capture-group
464  
465 =head3 ?|
466  
467 Not mentioned in any Delta. See B<(?|pattern)> in L<perlre/Extended Patterns>.
468  
469 Alias: regex-reset-branch
470  
471 =head3 quant+
472  
473 "Possessive Quantifiers" under L<perl5100delta/Regular expressions> or
474 L<perlre/Quantifiers>.
475  
476 Aliases: regex-possessive-quantifier regex-possessive-match
477  
478 =head3 regex-verbs
479  
480 "Backtracking control verbs" under L<perl5100delta/Regular
481 expressions> or L<perlre/Special Backtracking Control Verbs>.
482  
483  
484 =head3 \K
485  
486 "\K escape" under L<perl5100delta/Regular expressions> or
487 L<perlre/Look-Around Assertions>.
488  
489 Alias: regex-keep-left
490  
491 =head3 \R \v \h
492  
493 Covers C<\V> and C<\H>, too. See "Vertical and horizontal whitespace,
494 and linebreak" under L<perl5100delta/Regular expressions> or
495 L<perlrebackslash/Misc>.
496  
497 Aliases: \H \V regex-generic-linebreak regex-horizontal-whitespace regex-vertical-whitespace
498  
499 =head3 \gN
500  
501 "Relative backreferences" under L<perl5100delta/Regular expressions> or
502 L<perlre/Capture groups>.
503  
504 Alias: regex-relative-backreference
505  
506 =head3 readline()
507  
508 L<perl5100delta/Default argument for readline()>.
509  
510 Alias: readline-argv
511  
512 =head3 stack-file-test
513  
514 L<perl5100delta/Stacked filetest operators>.
515  
516 =head3 /p
517  
518 C</p> (preserve) modifier and C<${^PREMATCH}>, C<${^MATCH}> and
519 C<${^POSTMATCH}> variables. Not mentioned in any Delta. See
520 L<perlvar/Variables related to regular expressions>.
521  
522 Alias: regex-preserve-match-captures
523  
524 =head3 lexical-$_
525  
526 L<perl5100delta/Lexical $_>. Removed in 5.024.
527  
528 Alias: lexical-default-variable
529  
530 =head3 pack<
531  
532 See L<perl5100delta/Byte-order-modifiers-for-pack()-and-unpack()>
533  
534 Alias: pack-byte-order-modifiers
535  
536 =head2 5.012
537  
538 =head3 package-version
539  
540 L<perl5120delta/New package NAME VERSION syntax>
541  
542 =head3 ...
543  
544 L<perl5120delta/The ... operator> or L<perlsyn/The Ellipsis Statement>
545  
546 Aliases: yada-yada triple-dot statement-ellipsis
547  
548 =head3 each-array
549  
550 L<perl5120delta/each, keys, values are now more flexible>
551  
552 =head3 keys-array
553  
554 L<perl5120delta/each, keys, values are now more flexible>
555  
556 =head3 values-array
557  
558 L<perl5120delta/each, keys, values are now more flexible>
559  
560 =head3 delete-local
561  
562 L<perl5120delta/delete local>
563  
564 =head3 length-undef
565  
566 See the ninth bullet in L<perl5120delta/Other potentially incompatible
567 changes>.
568  
569 =head3 \N
570  
571 L<perl5120delta/\N experimental regex escape>.
572  
573 Alias: regex-non-newline
574  
575 =head3 while-readdir
576  
577 C<readdir> in a while-loop condition populates C<$_>. Not mentioned in
578 any delta, but see C<readdir> in L<perlfunc>.
579  
580 =head2 5.014
581  
582 =head3 ?^
583  
584 L<perl5140delta/Regular Expressions>.
585  
586 Alias: regex-use-default-modifiers
587  
588 =head3 /r
589  
590 L<perl5140delta/Regular Expressions> and L<perlre/Modifiers>.
591  
592 Aliases: non-destructive-subst non-destructive-substitution
593  
594 =head3 /d
595  
596 L<perl5140delta/Regular Expressions> and L<perlre/Modifiers>.
597  
598 Alias: regex-compile-as-default
599  
600 =head3 /l
601  
602 L<perl5140delta/Regular Expressions> and L<perlre/Modifiers>.
603  
604 Alias: regex-compile-as-locale
605  
606 =head3 /u
607  
608 L<perl5140delta/Regular Expressions> and L<perlre/Modifiers>.
609  
610 Aliases: regex-unicode-strings regex-compile-as-unicode-strings
611  
612 =head3 /a
613  
614 L<perl5140delta/Regular Expressions> and L<perlre/Modifiers>.
615  
616 Alias: regex-restrict-ascii-range
617  
618 =head3 auto-deref
619  
620 L<perl5140delta/Array and hash container functions accept
621 references>. See also C<push>, C<pop>, C<shift>, C<unshift>,
622 C<splice>, C<keys>, C<values>, and C<each> in L<perlfunc>.
623 Removed in 5.024.
624  
625 =head3 ^GLOBAL_PHASE
626  
627 See B<New global variable ${^GLOBAL_PHASE}> under
628 L<perl5140delta/Other Enhancements>.
629  
630 Alias: global-phase
631  
632 =head3 \o
633  
634 L<perl5140delta/Regular Expressions>.
635  
636 Alias: octal-escape
637  
638 =head3 package-block
639  
640 See B<package block syntax> under L<perl5140delta/Syntactical Enhancements>.
641  
642 =head3 srand-return
643  
644 See B<srand() now returns the seed> under L<perl5140delta/Other Enhancements>.
645  
646 =head3 prototype+
647  
648 See L<perl5140delta/Single-term-prototype>.
649  
650 =head3 sig-warn-obj
651  
652 See the second bullet in L<perl5140delta/Exception Handling>.
653  
654 =head2 5.016
655  
656 =head3 charnames
657  
658 See L<perl5160delta/use charnames is no longer needed for \N{name}>.
659  
660 =head3 __FILE__()
661  
662 See L<perl5160delta/__FILE__() Syntax>.
663  
664 Aliases: __LINE__() __PACKAGE__()
665  
666 =head2 5.018
667  
668 =head3 computed-labels
669  
670 L<perl5180delta/Computed Labels>
671  
672 =head3 while-each
673  
674 See in L<perl5180delta/Selected Bug Fixes> or C<each> in L<perlfunc>.
675  
676 =head3 method-on-any-string
677  
678 See [perl #105922] in L<perl5180delta/Selected Bug Fixes>.
679  
680 =head3 split-space
681  
682 See L<perl5180delta/split's first argument is more consistently interpreted>.
683  
684 =head2 5.020
685  
686 =head3 attr-prototype
687  
688 L<perl5200delta/subs now take a prototype attribute>
689  
690 Alias: attribute-prototype
691  
692 =head3 drand48
693  
694 L<perl5200delta/rand now uses a consistent random number generator>.
695 Note that on OpenBSD, Perl 5.020+ uses the system's own C<drand48>
696 unless seeded.
697  
698 =head3 %slice
699  
700 L<perl5200delta/New slice syntax>
701  
702 Alias: hash-slice
703  
704 =head3 unicode6.3
705  
706 L<perl5200delta/Unicode 6.3 now supported>
707  
708 Alias: unicode-6.3
709  
710 =head3 \p{Unicode}
711  
712 See B<New \p{Unicode} regular expression pattern property> in
713 L<perl5200delta/Core Enhancements>.
714  
715 Alias: regex-property-unicode
716  
717 =head3 utf8-locale
718  
719 See B<use locale now works on UTF-8 locales> in
720 L<perl5200delta/Core Enhancements>.
721  
722 =head3 s-utf8-delimiters
723  
724 See L<perl5200delta/Regular Expressions>: in older Perl versions, a
725 hack around was possible: to specify the delimiter twice in
726 substitution. Use C</s-utf8-delimiters-hack> if your code uses it.
727  
728 Alias: wide-char-delimiters
729  
730 =head2 5.022
731  
732 =head3 <<>>
733  
734 L<perl5220delta/New double-diamond operator>
735  
736 Aliases: double-diamond operator-double-diamond
737  
738 =head3 \b{}
739  
740 L<perl5220delta/New \b boundaries in regular expressions>
741  
742 Aliases: regex-unicode-grapheme-cluster-boundary regex-unicode-boundary regex-unicode-word-boundary regex-unicode-sentence-boundary regex-unicode-line-break-boundary \b{sb} \b{wb} \b{gcb}
743  
744 =head3 /n
745  
746 L<perl5220delta/Non-Capturing Regular Expression Flag>
747  
748 Alias: regex-non-capturing
749  
750 =head3 unicode7.0
751  
752 See B<Unicode 7.0 (with correction) is now supported> in
753 L<perl5220delta/Core Enhancements>.
754  
755 Alias: unicode-7.0
756  
757 =head3 attr-const
758  
759 L<perl5220delta/New :const subroutine attribute>
760  
761 Alias: attribute-const
762  
763 =head3 fileno-dir
764  
765 L<perl5220delta/fileno now works on directory handles>
766  
767 =head3 ()x=
768  
769 L<perl5220delta/Assignment to list repetition>
770  
771 Alias: list-repetition-assignment
772  
773 =head3 hexfloat
774  
775 L<perl5220delta/Floating point parsing has been improved>
776  
777 Alias: hexadecimal-floating-numbers
778  
779 =head3 chr-inf
780  
781 L<perl5220delta/Packing infinity or not-a-number into a character is now fatal>
782  
783 Alias: pack-inf
784  
785 =head3 empty-slice
786  
787 L<perl5220delta/List slices returning empty lists>
788  
789 =head3 /x-unicode
790  
791 See B<qr/foo/x now ignores all Unicode pattern white space> in
792 L<perl5220delta/Incompatible Changes>.
793  
794 Aliases: regex-x-unicode regex-x-handles-unicode
795  
796 =head2 5.024
797  
798 =head3 unicode8.0
799  
800 L<perl5240delta/Unicode 8.0 is now supported>.
801  
802 Alias: unicode-8.0
803  
804 =head3 \b{lb}
805  
806 L<perl5240delta/New \b{lb} boundary in regular expressions>.
807  
808 =head3 sprintf-reorder
809  
810 L<perl5240delta/printf and sprintf now allow reordered precision arguments>.
811  
812 Aliases: printf-precision-argument-reorder sprintf-precision-argument-reorder
813  
814 =head2 5.026
815  
816 =head3 <<~
817  
818 L<perl5260delta/Indented Here documents>.
819  
820 Alias: heredoc-indent
821  
822 =head3 /xx
823  
824 L<perl5260delta/New-regular-expression-modifier-/xx>.
825  
826 Alias: regex-xx
827  
828 =head3 ^CAPTURE
829  
830 See C<@{^CAPTURE}>, C<%{^CAPTURE}>, and C<%{^CAPTURE_ALL}> in
831 L<perl5260delta>.
832  
833 Alias: capture-variable
834  
835 =head3 unicode9.0
836  
837 L<perl5260delta/Unicode 9.0 is now supported>.
838  
839 Alias: unicode-9.0
840  
841 =head3 unicode-scx
842  
843 See I<"Use of \p{script} uses the improved Script_Extensions property">
844 in L<perl5260delta>.
845  
846 =head3 scalar%
847  
848 See L<perl5260delta/scalar(%hash) return signature changed>. Specifying this
849 construct means the 5.026+ behaviour, i.e. C<scalar %hash> returns the number
850 of keys.
851  
852 Alias: scalar-hash
853  
854 =head2 5.028
855  
856 =head3 delete%
857  
858 See L<perl5280delta/delete-on-key/value-hash-slices>.
859  
860 Alias: hash-delete-slice
861  
862 =head3 unicode10.0
863  
864 See L<perl5280delta/Unicode 10.0 is supported>.
865  
866 Alias: unicode-10.0
867  
868 =head3 state@=
869  
870 See L<perl5280delta/Initialisation-of-aggregate-state-variables>.
871  
872 Aliases: state-array state-hash list-context-state
873  
874 =head2 5.030
875  
876 =head3 unicode12.1
877  
878 L<perl5300delta/Unicode 12.1 is supported>
879  
880 Alias: unicode-12.1
881  
882 =head3 uniprop_wildcards
883  
884 L<perl5300delta/Wildcards in Unicode property value specifications are now partially supported>
885  
886 =head3 qr'N
887  
888 L<perl5300delta/qr'\N{name}' is now supported>
889  
890 Alias: named-char-in-single-quoted-regex
891  
892 =head3 turkic-casing
893  
894 See L<perl5300delta/Turkic UTF-8 locales are now seamlessly supported>.
895 B<Beware:> the actual behaviour depends on the operating system's
896 locale support. E.g. FreeBSD, DragonFly, and Solaris are known not to
897 support it.
898  
899 =head3 ^RE_COMPILE_RECURSION_LIMIT
900  
901 Not mentioned in any Delta. See L<perlvar/${^RE_COMPILE_RECURSION_LIMIT}>.
902  
903 Alias: re-compile-recursion-limit
904  
905 =head2 5.032
906  
907 =head3 unicode13.0
908  
909 L<perl5320delta/Unicode 13.0 is supported>
910  
911 Alias: unicode-13.0
912  
913 =head3 chained-comparisons
914  
915 L<perl5320delta/Chained comparisons capability>
916  
917 =head3 unicode-identifier-status
918  
919 L<perl5320delta/New Unicode properties Identifier_Status and Identifier_Type supported>
920  
921 Alias: unicode-identifier-type
922  
923 =head3 unicode-name-property
924  
925 L<It is now possible to write \p{Name=...} in perl5320delta|perl5320delta/It>
926  
927 =head2 5.034
928  
929 =head3 {,n}
930  
931 L<perl5340delta/qr/{,n}/ is now accepted>
932  
933 Alias: empty-left-quantifier
934  
935 =head3 0o
936  
937 L<perl5340delta/New octal syntax 0oddddd>
938  
939 Alias: octal-literals
940  
941 =head3 blanks-in-curlies
942  
943 L<perl5340delta/Blanks freely allowed within but adjacent to curly braces>
944  
945 =head2 5.036
946  
947 =head3 unicode14.0
948  
949 L<perl5360delta/Unicode 14.0 is supported>
950  
951 =head2 5.038
952  
953 =head3 unicode15.0
954  
955 L<perl5380delta/Unicode 15.0 is supported>
956  
957 =head3 ^HOOK
958  
959 L<perl5380delta/%{^HOOK} API introduced>
960  
961 Alias: keyword-hook
962  
963 =head3 signature-default-operator
964  
965 L<perl5380delta/Defined-or and logical-or assignment default expressions in signatures>
966  
967 =head3 INCDIR
968  
969 L<perl5380delta/@INC Hook Enhancements and $INC and INCDIR>
970  
971 =head3 *{}
972  
973 L<perl5380delta/Optimistic Eval in Patterns>
974  
975 Alias: optimistic-eval
976  
977 =head3 REG_INF_I32_MAX
978  
979 L<perl5380delta/REG_INF has been raised from 65,536 to 2,147,483,647>
980  
981 =head3 ^LAST_SUCCESSFUL_PATTERN
982  
983 L<perl5380delta/New regexp variable ${^LAST_SUCCESSFUL_PATTERN}>
984  
985 =head2 5.040
986  
987 =head3 ^^
988  
989 L<perl5400delta/New ^^ logical xor operator>
990  
991 Alias: logical-xor
992  
993 =head3 __CLASS__
994  
995 L<perl5400delta/New __CLASS__ Keyword>.
996  
997 =head3 :reader
998  
999 L<perl5400delta/:reader attribute for field variables>
1000  
1001 =head2 5.042
1002  
1003 =head3 :writer
1004  
1005 L<perl5420delta/New :writer attribute on field variables>
1006  
1007 =head3 my_method
1008  
1009 L<perl5420delta/Lexical method declaration using my method>
1010  
1011 =head3 ->&
1012  
1013 L<< perl5420delta/Lexical method invocation operator ->& >>
1014  
1015 Alias: lexical-method-invocation-operator
1016  
1017 =head3 unicode16.0
1018  
1019 L<perl5420delta/Unicode 16.0 supported>
1020  
1021 =head3 ^^=
1022  
1023 L<perl5420delta/Assigning logical xor ^^= operator>
1024  
1025 Alias: assign-logical-xor
1026  
1027 =head2 5.044
1028  
1029 =head3 named-params
1030  
1031 L<perldelta/Named Parameters in Signatures>
1032  
1033 =head3 multi-for-ref
1034  
1035 L<perldelta/Multi-variable foreach can now use aliased references>
1036  
1037 =head3 unicode17.0
1038  
1039 <perldelta/Unicode 17.0 is supported>
1040  
1041 =for completeness
1042 =head2 old
1043  
1044 =head2 Removed Constructs
1045  
1046 Only constructs not mentioned above are listed here, i.e. constructs
1047 that were introduced before 5.008001.
1048  
1049 =head3 ??
1050  
1051 Removed in 5.022. See L<perl5220delta/Support for ?PATTERN? without
1052 explicit operator has been removed>.
1053  
1054 =head3 no-sigil
1055  
1056 Removed in 5.022, not documented. Before that, if the first argument
1057 to C<shift>, C<unshift>, C<pop>, C<push>, C<splice>, C<keys>,
1058 C<values>, and C<each> was a global variable, it was possible to omit
1059 its sigil, e.g.
1060  
1061 push arr, 12; # same as push @arr, 12
1062  
1063 =head3 for-qw
1064  
1065 Removed in 5.018. See L<perl5180delta/qw(...)-can-no-longer-be-used-as-parentheses>.
1066  
1067 =head3 @_=split
1068  
1069 Removed in 5.012, but documented in 5.014. See L<perl5140delta/split()-and-@_>.
1070  
1071 Alias: split-populates-@_
1072  
1073 =head2 Accepted Features
1074  
1075 Some features have been accepted in Perl (C<postderef> and
1076 C<postderef_qq> in 5.024, C<lexical_subs> in 5.026). In the spirit of
1077 Syntax::Construct, you should still declare them, even if their usage
1078 has no effect in newer Perl versions to provide meaningful error
1079 messages to users of older versions.
1080  
1081 =head1 AUTHOR
1082  
1083 E. Choroba, C<< <choroba at cpan.org> >>
1084  
1085 =head2 Contributors
1086  
1087 Gabor Szabo, JJ Merelo, tynovsky, Chris White, Mohammad S Anwar,
1088 Branislav Zahradnik
1089  
1090 =head1 BUGS
1091  
1092 Please report any bugs or feature requests to the GitHub repository,
1093 see below.
1094  
1095 =head2 Unstable Perl Versions
1096  
1097 In development versions of Perl, the removal of constructs is tested
1098 against the coming stable version -- e.g., 5.023 forbids all the
1099 removed constructs of 5.024. The behaviour of the module in such
1100 circumstances might still be, um, unstable.
1101  
1102 =head1 SUPPORT
1103  
1104 You can find documentation for this module with the perldoc command.
1105  
1106 perldoc Syntax::Construct
1107  
1108 You can also look for information at:
1109  
1110 =over 4
1111  
1112 =item * GitHub Repository
1113  
1114 L<https://github.com/choroba/syntactic-construct>
1115  
1116 Feel free to report issues and submit pull requests.
1117  
1118 =item * MetaCPAN, Open Source Search Engine for CPAN
1119  
1120 L<https://metacpan.org/pod/Syntax::Construct>
1121  
1122 =item * Search CPAN
1123  
1124 L<http://search.cpan.org/dist/Syntax-Construct/>
1125  
1126 =back
1127  
1128 =head1 SEE ALSO
1129  
1130 L<Perl::MinimumVersion>, L<Perl::MinimumVersion::Fast>
1131  
1132 =head1 LICENSE AND COPYRIGHT
1133  
1134 Copyright 2013 - 2026 E. Choroba.
1135  
1136 This program is free software; you can redistribute it and/or modify it
1137 under the terms of the the Artistic License (2.0). You may obtain a
1138 copy of the full license at:
1139  
1140 L<http://www.perlfoundation.org/artistic_license_2_0>
1141  
1142 Any use, modification, and distribution of the Standard or Modified
1143 Versions is governed by this Artistic License. By using, modifying or
1144 distributing the Package, you accept this license. Do not use, modify,
1145 or distribute the Package, if you do not accept this license.
1146  
1147 If your Modified Version has been derived from a Modified Version made
1148 by someone other than you, you are nevertheless required to ensure that
1149 your Modified Version complies with the requirements of this license.
1150  
1151 This license does not grant you the right to use any trademark, service
1152 mark, tradename, or logo of the Copyright Holder.
1153  
1154 This license includes the non-exclusive, worldwide, free-of-charge
1155 patent license to make, have made, use, offer to sell, sell, import and
1156 otherwise transfer the Package with respect to any patent claims
1157 licensable by the Copyright Holder that are necessarily infringed by the
1158 Package. If you institute patent litigation (including a cross-claim or
1159 counterclaim) against any party alleging that the Package constitutes
1160 direct or contributory patent infringement, then this Artistic License
1161 to you shall terminate on the date that such litigation is filed.
1162  
1163 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
1164 AND CONTRIBUTORS "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
1165 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
1166 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
1167 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
1168 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
1169 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
1170 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1171  
1172  
1173 =cut
1174  
1175 7 __PACKAGE__
↑ Summary