3 # Regenerate (overwriting only if changed):
8 # from information hardcoded into this script and from two #defines
11 # This script is normally invoked from regen.pl.
14 require './regen/regen_lib.pl';
21 ###########################################################################
24 # (feature name) => (internal name, used in %^H and macro names)
30 evalbytes => 'evalbytes',
31 current_sub => '__SUB__',
32 refaliasing => 'refaliasing',
33 postderef_qq => 'postderef_qq',
34 unicode_eval => 'unieval',
35 declared_refs => 'myref',
36 unicode_strings => 'unicode',
38 signatures => 'signatures',
40 indirect => 'indirect',
41 multidimensional => 'multidimensional',
44 # NOTE: If a feature is ever enabled in a non-contiguous range of Perl
45 # versions, any code below that uses %BundleRanges will have to
46 # be changed to account.
48 # 5.odd implies the next 5.even, but an explicit 5.even can override it.
51 use constant V5_9_5 => sort qw{say state switch indirect multidimensional};
52 use constant V5_11 => sort ( +V5_9_5, qw{unicode_strings} );
53 use constant V5_15 => sort ( +V5_11, qw{unicode_eval evalbytes current_sub fc} );
54 use constant V5_23 => sort ( +V5_15, qw{postderef_qq} );
55 use constant V5_27 => sort ( +V5_23, qw{bitwise} );
57 my %feature_bundle = (
58 all => [ sort keys %feature ],
59 default => [ qw{indirect multidimensional} ],
60 # using 5.9.5 features bundle
61 "5.9.5" => [ +V5_9_5 ],
62 "5.10" => [ +V5_9_5 ],
63 # using 5.11 features bundle
66 # using 5.15 features bundle
71 # using 5.23 features bundle
74 # using 5.27 features bundle
81 my @noops = qw( postderef lexical_subs );
82 my @removed = qw( array_base );
85 ###########################################################################
86 # More data generated from the above
88 if (keys %feature > 32) {
89 die "cop_features only has room for 32 features";
94 for my $feature (sort keys %feature) {
95 $feature_bits{$feature} = $mask;
99 for (keys %feature_bundle) {
100 next unless /^5\.(\d*[13579])\z/;
101 $feature_bundle{"5.".($1+1)} ||= $feature_bundle{$_};
104 my %UniqueBundles; # "say state switch" => 5.10
105 my %Aliases; # 5.12 => 5.11
106 for( sort keys %feature_bundle ) {
107 my $value = join(' ', sort @{$feature_bundle{$_}});
108 if (exists $UniqueBundles{$value}) {
109 $Aliases{$_} = $UniqueBundles{$value};
112 $UniqueBundles{$value} = $_;
116 my %BundleRanges; # say => ['5.10', '5.15'] # unique bundles for values
118 sort { $a eq 'default' ? -1 : $b eq 'default' ? 1 : $a cmp $b }
119 values %UniqueBundles
121 next if $bund =~ /[^\d.]/ and $bund ne 'default';
122 for (@{$feature_bundle{$bund}}) {
123 if (@{$BundleRanges{$_} ||= []} == 2) {
124 $BundleRanges{$_}[1] = $bund
127 push @{$BundleRanges{$_}}, $bund;
136 open "perl.h", "<", "perl.h" or die "$0 cannot open perl.h: $!";
137 while (readline "perl.h") {
138 next unless /#\s*define\s+(HINT_FEATURE_MASK|HINT_UNI_8_BIT)/;
139 my $is_u8b = $1 =~ 8;
140 /(0x[A-Fa-f0-9]+)/ or die "No hex number in:\n\n$_\n ";
145 my $hex = $HintMask = $1;
146 my $bits = sprintf "%b", oct $1;
147 $bits =~ /^0*1+(0*)\z/
148 or die "Non-contiguous bits in $bits (binary for $hex):\n\n$_\n ";
149 $HintShift = length $1;
151 length sprintf "%b", scalar keys %UniqueBundles;
152 $bits =~ /1{$bits_needed}/
153 or die "Not enough bits (need $bits_needed)"
154 . " in $bits (binary for $hex):\n\n$_\n ";
156 if ($Uni8Bit && $HintMask) { last }
158 die "No HINT_FEATURE_MASK defined in perl.h" unless $HintMask;
159 die "No HINT_UNI_8_BIT defined in perl.h" unless $Uni8Bit;
164 ('default', grep !/[^\d.]/, sort values %UniqueBundles);
167 ###########################################################################
168 # Open files to be generated
171 open_new($_, '>', { by => 'regen/feature.pl' });
172 } 'lib/feature.pm', 'feature.h';
175 ###########################################################################
176 # Generate lib/feature.pm
179 last if /^FEATURES$/ ;
186 if (!defined $long or length $long < length) {
193 print $pm "our %feature = (\n";
194 my $width = length longest keys %feature;
195 for(sort { length $a <=> length $b || $a cmp $b } keys %feature) {
196 print $pm " $_" . " "x($width-length)
197 . " => 'feature_$feature{$_}',\n";
201 print $pm "our %feature_bundle = (\n";
202 my $bund_width = length longest values %UniqueBundles;
203 for( sort { $UniqueBundles{$a} cmp $UniqueBundles{$b} }
204 keys %UniqueBundles ) {
205 my $bund = $UniqueBundles{$_};
206 print $pm qq' "$bund"' . " "x($bund_width-length $bund)
207 . qq' => [qw($_)],\n';
211 for (sort keys %Aliases) {
213 qq'\$feature_bundle{"$_"} = \$feature_bundle{"$Aliases{$_}"};\n';
216 print $pm "my \%noops = (\n";
217 print $pm " $_ => 1,\n", for @noops;
220 print $pm "my \%removed = (\n";
221 print $pm " $_ => 1,\n", for @removed;
226 our \$hint_shift = $HintShift;
227 our \$hint_mask = $HintMask;
228 our \@hint_bundles = qw( @HintedBundles );
230 # This gets set (for now) in \$^H as well as in %^H,
231 # for runtime speed of the uc/lc/ucfirst/lcfirst functions.
232 # See HINT_UNI_8_BIT in perl.h.
233 our \$hint_uni8bit = $Uni8Bit;
238 last if /^PODTURES$/ ;
242 select +(select($pm), $~ = 'PODTURES')[0];
244 ^<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
245 $::bundle, $::feature
248 for ('default', sort grep /\.\d[02468]/, keys %feature_bundle) {
250 $::feature = join ' ', @{$feature_bundle{$_}};
259 read_only_bottom_close_and_rename($pm);
262 ###########################################################################
267 #ifndef PERL_FEATURE_H_
268 #define PERL_FEATURE_H_
270 #if defined(PERL_CORE) || defined (PERL_EXT)
272 #define HINT_FEATURE_SHIFT $HintShift
276 for (sort keys %feature_bits) {
277 printf $h "#define FEATURE_%s_BIT%*s %#06x\n", uc($feature{$_}),
278 $width-length($feature{$_}), "", $feature_bits{$_};
283 for (@HintedBundles) {
284 (my $key = uc) =~ y/.//d;
285 print $h "#define FEATURE_BUNDLE_$key ", $count++, "\n";
289 #define FEATURE_BUNDLE_CUSTOM (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
291 #define CURRENT_HINTS \
292 (PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
293 #define CURRENT_FEATURE_BUNDLE \
294 ((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)
296 #define FEATURE_IS_ENABLED_MASK(mask) \
297 ((CURRENT_HINTS & HINT_LOCALIZE_HH) \
298 ? (PL_curcop->cop_features & (mask)) : FALSE)
300 /* The longest string we pass in. */
303 my $longest_internal_feature_name = longest values %feature;
305 #define MAX_FEATURE_LEN (sizeof("$longest_internal_feature_name")-1)
310 sort { length $a <=> length $b || $a cmp $b } keys %feature
313 map { (my $__ = uc) =~ y/.//d; $__ } @{$BundleRanges{$_}};
314 my $name = $feature{$_};
316 if ($last && $first eq 'DEFAULT') { # '>= DEFAULT' warns
318 #define FEATURE_${NAME}_IS_ENABLED \\
320 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_$last \\
321 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
322 FEATURE_IS_ENABLED_MASK(FEATURE_${NAME}_BIT)) \\
329 #define FEATURE_${NAME}_IS_ENABLED \\
331 (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_$first && \\
332 CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_$last) \\
333 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
334 FEATURE_IS_ENABLED_MASK(FEATURE_${NAME}_BIT)) \\
341 #define FEATURE_${NAME}_IS_ENABLED \\
343 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_$first \\
344 || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
345 FEATURE_IS_ENABLED_MASK(FEATURE_${NAME}_BIT)) \\
352 #define FEATURE_${NAME}_IS_ENABLED \\
354 CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \\
355 FEATURE_IS_ENABLED_MASK(FEATURE_${NAME}_BIT) \\
364 #define SAVEFEATUREBITS() SAVEI32(PL_compiling.cop_features)
366 #define CLEARFEATUREBITS() (PL_compiling.cop_features = 0)
368 #define STOREFEATUREBITSHH(hh) \\
369 (hv_stores((hh), "feature/bits", newSVuv(PL_compiling.cop_features)))
371 #define FETCHFEATUREBITSHH(hh) \\
373 SV **fbsv = hv_fetchs((hh), "feature/bits", FALSE); \\
374 PL_compiling.cop_features = fbsv ? SvUV(*fbsv) : 0; \\
377 #endif /* PERL_CORE or PERL_EXT */
380 PERL_STATIC_INLINE void
381 S_enable_feature_bundle(pTHX_ SV *ver)
383 SV *comp_ver = sv_newmortal();
384 PL_hints = (PL_hints &~ HINT_FEATURE_MASK)
388 for (reverse @HintedBundles[1..$#HintedBundles]) { # skip default
390 if ($numver eq '5.10') { $numver = '5.009005' } # special case
391 else { $numver =~ s/\./.0/ } # 5.11 => 5.011
392 (my $macrover = $_) =~ y/.//d;
394 (sv_setnv(comp_ver, $numver),
395 vcmp(ver, upg_version(comp_ver, FALSE)) >= 0)
396 ? FEATURE_BUNDLE_$macrover :
401 FEATURE_BUNDLE_DEFAULT
402 ) << HINT_FEATURE_SHIFT;
404 assert(PL_curcop == &PL_compiling);
405 if (FEATURE_UNICODE_IS_ENABLED) PL_hints |= HINT_UNI_8_BIT;
406 else PL_hints &= ~HINT_UNI_8_BIT;
408 #endif /* PERL_IN_OP_C */
412 #define magic_sethint_feature(keysv, keypv, keylen, valsv, valbool) \\
413 S_magic_sethint_feature(aTHX_ (keysv), (keypv), (keylen), (valsv), (valbool))
414 PERL_STATIC_INLINE void
415 S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen,
416 SV *valsv, bool valbool) {
418 keypv = SvPV_const(keysv, keylen);
420 if (memBEGINs(keypv, keylen, "feature_")) {
421 const char *subf = keypv + (sizeof("feature_")-1);
427 for my $key (sort values %feature) {
428 push @{$pref{substr($key, 0, 1)}}, $key;
431 for my $pref (sort keys %pref) {
436 for my $subkey (@{$pref{$pref}}) {
437 my $rest = substr($subkey, 1);
438 my $if = $first ? "if" : "else if";
440 $if (keylen == sizeof("feature_$subkey")-1
441 && memcmp(subf+1, "$rest", keylen - sizeof("feature_")) == 0) {
442 mask = FEATURE_\U${subkey}\E_BIT;
459 if (valsv ? SvTRUE(valsv) : valbool)
460 PL_compiling.cop_features |= mask;
462 PL_compiling.cop_features &= ~mask;
465 #endif /* PERL_IN_MG_C */
467 #endif /* PERL_FEATURE_H_ */
470 read_only_bottom_close_and_rename($h);
473 ###########################################################################
474 # Template for feature.pm
479 our $VERSION = '1.60';
484 # - think about versioned features (use feature switch => 2)
488 feature - Perl pragma to enable new features
492 use feature qw(say switch);
494 when (1) { say "\$foo == 1" }
495 when ([2,3]) { say "\$foo == 2 || \$foo == 3" }
496 when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
497 when ($_ > 100) { say "\$foo > 100" }
498 default { say "None of the above" }
501 use feature ':5.10'; # loads all features available in perl 5.10
503 use v5.10; # implicitly loads :5.10 feature bundle
507 It is usually impossible to add new syntax to Perl without breaking
508 some existing programs. This pragma provides a way to minimize that
509 risk. New syntactic constructs, or new semantic meanings to older
510 constructs, can be enabled by C<use feature 'foo'>, and will be parsed
511 only when the appropriate feature pragma is in scope. (Nevertheless, the
512 C<CORE::> prefix provides access to all Perl keywords, regardless of this
515 =head2 Lexical effect
517 Like other pragmas (C<use strict>, for example), features have a lexical
518 effect. C<use feature qw(foo)> will only make the feature "foo" available
519 from that point to the end of the enclosing block.
523 say "say is available here";
525 print "But not here.\n";
529 Features can also be turned off by using C<no feature "foo">. This too
533 say "say is available here";
536 print "But not here.\n";
538 say "Yet it is here.";
540 C<no feature> with no features specified will reset to the default group. To
541 disable I<all> features (an unusual request!) use C<no feature ':all'>.
543 =head1 AVAILABLE FEATURES
545 =head2 The 'say' feature
547 C<use feature 'say'> tells the compiler to enable the Perl 6 style
550 See L<perlfunc/say> for details.
552 This feature is available starting with Perl 5.10.
554 =head2 The 'state' feature
556 C<use feature 'state'> tells the compiler to enable C<state>
559 See L<perlsub/"Persistent Private Variables"> for details.
561 This feature is available starting with Perl 5.10.
563 =head2 The 'switch' feature
565 B<WARNING>: Because the L<smartmatch operator|perlop/"Smartmatch Operator"> is
566 experimental, Perl will warn when you use this feature, unless you have
567 explicitly disabled the warning:
569 no warnings "experimental::smartmatch";
571 C<use feature 'switch'> tells the compiler to enable the Perl 6
572 given/when construct.
574 See L<perlsyn/"Switch Statements"> for details.
576 This feature is available starting with Perl 5.10.
578 =head2 The 'unicode_strings' feature
580 C<use feature 'unicode_strings'> tells the compiler to use Unicode rules
581 in all string operations executed within its scope (unless they are also
582 within the scope of either C<use locale> or C<use bytes>). The same applies
583 to all regular expressions compiled within the scope, even if executed outside
584 it. It does not change the internal representation of strings, but only how
585 they are interpreted.
587 C<no feature 'unicode_strings'> tells the compiler to use the traditional
588 Perl rules wherein the native character set rules is used unless it is
589 clear to Perl that Unicode is desired. This can lead to some surprises
590 when the behavior suddenly changes. (See
591 L<perlunicode/The "Unicode Bug"> for details.) For this reason, if you are
592 potentially using Unicode in your program, the
593 C<use feature 'unicode_strings'> subpragma is B<strongly> recommended.
595 This feature is available starting with Perl 5.12; was almost fully
596 implemented in Perl 5.14; and extended in Perl 5.16 to cover C<quotemeta>;
597 was extended further in Perl 5.26 to cover L<the range
598 operator|perlop/Range Operators>; and was extended again in Perl 5.28 to
599 cover L<special-cased whitespace splitting|perlfunc/split>.
601 =head2 The 'unicode_eval' and 'evalbytes' features
603 Together, these two features are intended to replace the legacy string
604 C<eval> function, which behaves problematically in some instances. They are
605 available starting with Perl 5.16, and are enabled by default by a
606 S<C<use 5.16>> or higher declaration.
608 C<unicode_eval> changes the behavior of plain string C<eval> to work more
609 consistently, especially in the Unicode world. Certain (mis)behaviors
610 couldn't be changed without breaking some things that had come to rely on
611 them, so the feature can be enabled and disabled. Details are at
612 L<perlfunc/Under the "unicode_eval" feature>.
614 C<evalbytes> is like string C<eval>, but operating on a byte stream that is
615 not UTF-8 encoded. Details are at L<perlfunc/evalbytes EXPR>. Without a
616 S<C<use feature 'evalbytes'>> nor a S<C<use v5.16>> (or higher) declaration in
617 the current scope, you can still access it by instead writing
620 =head2 The 'current_sub' feature
622 This provides the C<__SUB__> token that returns a reference to the current
623 subroutine or C<undef> outside of a subroutine.
625 This feature is available starting with Perl 5.16.
627 =head2 The 'array_base' feature
629 This feature supported the legacy C<$[> variable. See L<perlvar/$[>.
630 It was on by default but disabled under C<use v5.16> (see
631 L</IMPLICIT LOADING>, below) and unavailable since perl 5.30.
633 This feature is available under this name starting with Perl 5.16. In
634 previous versions, it was simply on all the time, and this pragma knew
637 =head2 The 'fc' feature
639 C<use feature 'fc'> tells the compiler to enable the C<fc> function,
640 which implements Unicode casefolding.
642 See L<perlfunc/fc> for details.
644 This feature is available from Perl 5.16 onwards.
646 =head2 The 'lexical_subs' feature
648 In Perl versions prior to 5.26, this feature enabled
649 declaration of subroutines via C<my sub foo>, C<state sub foo>
650 and C<our sub foo> syntax. See L<perlsub/Lexical Subroutines> for details.
652 This feature is available from Perl 5.18 onwards. From Perl 5.18 to 5.24,
653 it was classed as experimental, and Perl emitted a warning for its
654 usage, except when explicitly disabled:
656 no warnings "experimental::lexical_subs";
658 As of Perl 5.26, use of this feature no longer triggers a warning, though
659 the C<experimental::lexical_subs> warning category still exists (for
660 compatibility with code that disables it). In addition, this syntax is
661 not only no longer experimental, but it is enabled for all Perl code,
662 regardless of what feature declarations are in scope.
664 =head2 The 'postderef' and 'postderef_qq' features
666 The 'postderef_qq' feature extends the applicability of L<postfix
667 dereference syntax|perlref/Postfix Dereference Syntax> so that postfix array
668 and scalar dereference are available in double-quotish interpolations. For
669 example, it makes the following two statements equivalent:
671 my $s = "[@{ $h->{a} }]";
672 my $s = "[$h->{a}->@*]";
674 This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it
675 was classed as experimental, and Perl emitted a warning for its
676 usage, except when explicitly disabled:
678 no warnings "experimental::postderef";
680 As of Perl 5.24, use of this feature no longer triggers a warning, though
681 the C<experimental::postderef> warning category still exists (for
682 compatibility with code that disables it).
684 The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable
685 postfix dereference syntax outside double-quotish interpolations. In those
686 versions, using it triggered the C<experimental::postderef> warning in the
687 same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is
688 not only no longer experimental, but it is enabled for all Perl code,
689 regardless of what feature declarations are in scope.
691 =head2 The 'signatures' feature
693 B<WARNING>: This feature is still experimental and the implementation may
694 change in future versions of Perl. For this reason, Perl will
695 warn when you use the feature, unless you have explicitly disabled the
698 no warnings "experimental::signatures";
700 This enables unpacking of subroutine arguments into lexical variables
703 sub foo ($left, $right) {
704 return $left + $right;
707 See L<perlsub/Signatures> for details.
709 This feature is available from Perl 5.20 onwards.
711 =head2 The 'refaliasing' feature
713 B<WARNING>: This feature is still experimental and the implementation may
714 change in future versions of Perl. For this reason, Perl will
715 warn when you use the feature, unless you have explicitly disabled the
718 no warnings "experimental::refaliasing";
720 This enables aliasing via assignment to references:
722 \$a = \$b; # $a and $b now point to the same scalar
723 \@a = \@b; # to the same array
726 foreach \%hash (@array_of_hash_refs) {
730 See L<perlref/Assigning to References> for details.
732 This feature is available from Perl 5.22 onwards.
734 =head2 The 'bitwise' feature
736 This makes the four standard bitwise operators (C<& | ^ ~>) treat their
737 operands consistently as numbers, and introduces four new dotted operators
738 (C<&. |. ^. ~.>) that treat their operands consistently as strings. The
739 same applies to the assignment variants (C<&= |= ^= &.= |.= ^.=>).
741 See L<perlop/Bitwise String Operators> for details.
743 This feature is available from Perl 5.22 onwards. Starting in Perl 5.28,
744 C<use v5.28> will enable the feature. Before 5.28, it was still
745 experimental and would emit a warning in the "experimental::bitwise"
748 =head2 The 'declared_refs' feature
750 B<WARNING>: This feature is still experimental and the implementation may
751 change in future versions of Perl. For this reason, Perl will
752 warn when you use the feature, unless you have explicitly disabled the
755 no warnings "experimental::declared_refs";
757 This allows a reference to a variable to be declared with C<my>, C<state>,
758 our C<our>, or localized with C<local>. It is intended mainly for use in
759 conjunction with the "refaliasing" feature. See L<perlref/Declaring a
760 Reference to a Variable> for examples.
762 This feature is available from Perl 5.26 onwards.
764 =head2 The 'isa' feature
766 This allows the use of the C<isa> infix operator, which tests whether the
767 scalar given by the left operand is an object of the class given by the
768 right operand. See L<perlop/Class Instance Operator> for more details.
770 This feature is available from Perl 5.32 onwards.
772 =head2 The 'indirect' feature
774 This feature allows the use of L<indirect object
775 syntax|perlobj/Indirect Object Syntax> for method calls, e.g. C<new
776 Foo 1, 2;>. It is enabled by default, but can be turned off to
777 disallow indirect object syntax.
779 This feature is available under this name from Perl 5.32 onwards. In
780 previous versions, it was simply on all the time. To disallow (or
781 warn on) indirect object syntax on older Perls, see the L<indirect>
784 =head2 The 'multidimensional' feature
786 This feature enables multidimensional array emulation, a perl 4 (or
787 earlier) feature that was used to emulate multidimensional arrays with
788 hashes. This works by converting code like C<< $foo{$x, y} >> into
789 C<< $foo{join($;, $x, $y} >>. It is enabled by default, but can be
790 turned off to disable multidimensional array emulation.
792 When this feature is disabled the syntax that is normally replaced
793 will report a compilation error.
795 This feature is available under this name from Perl 5.34 onwards. In
796 previous versions, it was simply on all the time.
798 You can use the L<multidimensional> module on CPAN to disable
799 multidimensional array emulation for older versions of Perl.
801 =head1 FEATURE BUNDLES
803 It's possible to load multiple features together, using
804 a I<feature bundle>. The name of a feature bundle is prefixed with
805 a colon, to distinguish it from an actual feature.
809 The following feature bundles are available:
811 bundle features included
812 --------- -----------------
814 The C<:default> bundle represents the feature set that is enabled before
815 any C<use feature> or C<no feature> declaration.
817 Specifying sub-versions such as the C<0> in C<5.14.0> in feature bundles has
818 no effect. Feature bundles are guaranteed to be the same for all sub-versions.
820 use feature ":5.14.0"; # same as ":5.14"
821 use feature ":5.14.1"; # same as ":5.14"
823 =head1 IMPLICIT LOADING
825 Instead of loading feature bundles by name, it is easier to let Perl do
826 implicit loading of a feature bundle for you.
828 There are two ways to load the C<feature> pragma implicitly:
834 By using the C<-E> switch on the Perl command-line instead of C<-e>.
835 That will enable the feature bundle for that version of Perl in the
836 main compilation unit (that is, the one-liner that follows C<-E>).
840 By explicitly requiring a minimum Perl version number for your program, with
841 the C<use VERSION> construct. That is,
850 and so on. Note how the trailing sub-version
851 is automatically stripped from the
854 But to avoid portability warnings (see L<perlfunc/use>), you may prefer:
858 with the same effect.
860 If the required version is older than Perl 5.10, the ":default" feature
861 bundle is automatically loaded instead.
863 Unlike C<use feature ":5.12">, saying C<use v5.12> (or any higher version)
864 also does the equivalent of C<use strict>; see L<perlfunc/use> for details.
874 croak("No features specified");
883 # A bare C<no feature> should reset to the default bundle
885 $^H &= ~($hint_uni8bit|$hint_mask);
895 my $bundle_number = $^H & $hint_mask;
896 my $features = $bundle_number != $hint_mask
897 && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]};
899 # Features are enabled implicitly via bundle hints.
900 # Delete any keys that may be left over from last time.
901 delete @^H{ values(%feature) };
904 $^H{$feature{$_}} = 1;
905 $^H |= $hint_uni8bit if $_ eq 'unicode_strings';
910 if (substr($name, 0, 1) eq ":") {
911 my $v = substr($name, 1);
912 if (!exists $feature_bundle{$v}) {
913 $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
914 if (!exists $feature_bundle{$v}) {
915 unknown_feature_bundle(substr($name, 1));
918 unshift @_, @{$feature_bundle{$v}};
921 if (!exists $feature{$name}) {
922 if (exists $noops{$name}) {
925 if (!$import && exists $removed{$name}) {
928 unknown_feature($name);
931 $^H{$feature{$name}} = 1;
932 $^H |= $hint_uni8bit if $name eq 'unicode_strings';
934 delete $^H{$feature{$name}};
935 $^H &= ~ $hint_uni8bit if $name eq 'unicode_strings';
940 sub unknown_feature {
942 croak(sprintf('Feature "%s" is not supported by Perl %vd',
946 sub unknown_feature_bundle {
948 croak(sprintf('Feature bundle "%s" is not supported by Perl %vd',