| 1 | # -*- buffer-read-only: t -*- | ||
| 2 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | ||
| 3 | # This file is built by regen/feature.pl. | ||
| 4 | # Any changes made here will be lost! | ||
| 5 | |||
| 6 | package feature; | ||
| 7 | |||
| 8 | our $VERSION = '1.47'; | ||
| 9 | |||
| 10 | our %feature = ( | ||
| 11 | fc => 'feature_fc', | ||
| 12 | say => 'feature_say', | ||
| 13 | state => 'feature_state', | ||
| 14 | switch => 'feature_switch', | ||
| 15 | bitwise => 'feature_bitwise', | ||
| 16 | evalbytes => 'feature_evalbytes', | ||
| 17 | array_base => 'feature_arybase', | ||
| 18 | signatures => 'feature_signatures', | ||
| 19 | current_sub => 'feature___SUB__', | ||
| 20 | refaliasing => 'feature_refaliasing', | ||
| 21 | postderef_qq => 'feature_postderef_qq', | ||
| 22 | unicode_eval => 'feature_unieval', | ||
| 23 | declared_refs => 'feature_myref', | ||
| 24 | unicode_strings => 'feature_unicode', | ||
| 25 | ); | ||
| 26 | |||
| 27 | our %feature_bundle = ( | ||
| 28 | "5.10" => [qw(array_base say state switch)], | ||
| 29 | "5.11" => [qw(array_base say state switch unicode_strings)], | ||
| 30 | "5.15" => [qw(current_sub evalbytes fc say state switch unicode_eval unicode_strings)], | ||
| 31 | "5.23" => [qw(current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)], | ||
| 32 | "all" => [qw(array_base bitwise current_sub declared_refs evalbytes fc postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], | ||
| 33 | "default" => [qw(array_base)], | ||
| 34 | ); | ||
| 35 | |||
| 36 | $feature_bundle{"5.12"} = $feature_bundle{"5.11"}; | ||
| 37 | $feature_bundle{"5.13"} = $feature_bundle{"5.11"}; | ||
| 38 | $feature_bundle{"5.14"} = $feature_bundle{"5.11"}; | ||
| 39 | $feature_bundle{"5.16"} = $feature_bundle{"5.15"}; | ||
| 40 | $feature_bundle{"5.17"} = $feature_bundle{"5.15"}; | ||
| 41 | $feature_bundle{"5.18"} = $feature_bundle{"5.15"}; | ||
| 42 | $feature_bundle{"5.19"} = $feature_bundle{"5.15"}; | ||
| 43 | $feature_bundle{"5.20"} = $feature_bundle{"5.15"}; | ||
| 44 | $feature_bundle{"5.21"} = $feature_bundle{"5.15"}; | ||
| 45 | $feature_bundle{"5.22"} = $feature_bundle{"5.15"}; | ||
| 46 | $feature_bundle{"5.24"} = $feature_bundle{"5.23"}; | ||
| 47 | $feature_bundle{"5.25"} = $feature_bundle{"5.23"}; | ||
| 48 | $feature_bundle{"5.26"} = $feature_bundle{"5.23"}; | ||
| 49 | $feature_bundle{"5.9.5"} = $feature_bundle{"5.10"}; | ||
| 50 | my %noops = ( | ||
| 51 | postderef => 1, | ||
| 52 | lexical_subs => 1, | ||
| 53 | ); | ||
| 54 | |||
| 55 | our $hint_shift = 26; | ||
| 56 | our $hint_mask = 0x1c000000; | ||
| 57 | our @hint_bundles = qw( default 5.10 5.11 5.15 5.23 ); | ||
| 58 | |||
| 59 | # This gets set (for now) in $^H as well as in %^H, | ||
| 60 | # for runtime speed of the uc/lc/ucfirst/lcfirst functions. | ||
| 61 | # See HINT_UNI_8_BIT in perl.h. | ||
| 62 | our $hint_uni8bit = 0x00000800; | ||
| 63 | |||
| 64 | # TODO: | ||
| 65 | # - think about versioned features (use feature switch => 2) | ||
| 66 | |||
| 67 | =head1 NAME | ||
| 68 | |||
| 69 | feature - Perl pragma to enable new features | ||
| 70 | |||
| 71 | =head1 SYNOPSIS | ||
| 72 | |||
| 73 | use feature qw(say switch); | ||
| 74 | given ($foo) { | ||
| 75 | when (1) { say "\$foo == 1" } | ||
| 76 | when ([2,3]) { say "\$foo == 2 || \$foo == 3" } | ||
| 77 | when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" } | ||
| 78 | when ($_ > 100) { say "\$foo > 100" } | ||
| 79 | default { say "None of the above" } | ||
| 80 | } | ||
| 81 | |||
| 82 | use feature ':5.10'; # loads all features available in perl 5.10 | ||
| 83 | |||
| 84 | use v5.10; # implicitly loads :5.10 feature bundle | ||
| 85 | |||
| 86 | =head1 DESCRIPTION | ||
| 87 | |||
| 88 | It is usually impossible to add new syntax to Perl without breaking | ||
| 89 | some existing programs. This pragma provides a way to minimize that | ||
| 90 | risk. New syntactic constructs, or new semantic meanings to older | ||
| 91 | constructs, can be enabled by C<use feature 'foo'>, and will be parsed | ||
| 92 | only when the appropriate feature pragma is in scope. (Nevertheless, the | ||
| 93 | C<CORE::> prefix provides access to all Perl keywords, regardless of this | ||
| 94 | pragma.) | ||
| 95 | |||
| 96 | =head2 Lexical effect | ||
| 97 | |||
| 98 | Like other pragmas (C<use strict>, for example), features have a lexical | ||
| 99 | effect. C<use feature qw(foo)> will only make the feature "foo" available | ||
| 100 | from that point to the end of the enclosing block. | ||
| 101 | |||
| 102 | { | ||
| 103 | use feature 'say'; | ||
| 104 | say "say is available here"; | ||
| 105 | } | ||
| 106 | print "But not here.\n"; | ||
| 107 | |||
| 108 | =head2 C<no feature> | ||
| 109 | |||
| 110 | Features can also be turned off by using C<no feature "foo">. This too | ||
| 111 | has lexical effect. | ||
| 112 | |||
| 113 | use feature 'say'; | ||
| 114 | say "say is available here"; | ||
| 115 | { | ||
| 116 | no feature 'say'; | ||
| 117 | print "But not here.\n"; | ||
| 118 | } | ||
| 119 | say "Yet it is here."; | ||
| 120 | |||
| 121 | C<no feature> with no features specified will reset to the default group. To | ||
| 122 | disable I<all> features (an unusual request!) use C<no feature ':all'>. | ||
| 123 | |||
| 124 | =head1 AVAILABLE FEATURES | ||
| 125 | |||
| 126 | =head2 The 'say' feature | ||
| 127 | |||
| 128 | C<use feature 'say'> tells the compiler to enable the Perl 6 style | ||
| 129 | C<say> function. | ||
| 130 | |||
| 131 | See L<perlfunc/say> for details. | ||
| 132 | |||
| 133 | This feature is available starting with Perl 5.10. | ||
| 134 | |||
| 135 | =head2 The 'state' feature | ||
| 136 | |||
| 137 | C<use feature 'state'> tells the compiler to enable C<state> | ||
| 138 | variables. | ||
| 139 | |||
| 140 | See L<perlsub/"Persistent Private Variables"> for details. | ||
| 141 | |||
| 142 | This feature is available starting with Perl 5.10. | ||
| 143 | |||
| 144 | =head2 The 'switch' feature | ||
| 145 | |||
| 146 | B<WARNING>: Because the L<smartmatch operator|perlop/"Smartmatch Operator"> is | ||
| 147 | experimental, Perl will warn when you use this feature, unless you have | ||
| 148 | explicitly disabled the warning: | ||
| 149 | |||
| 150 | no warnings "experimental::smartmatch"; | ||
| 151 | |||
| 152 | C<use feature 'switch'> tells the compiler to enable the Perl 6 | ||
| 153 | given/when construct. | ||
| 154 | |||
| 155 | See L<perlsyn/"Switch Statements"> for details. | ||
| 156 | |||
| 157 | This feature is available starting with Perl 5.10. | ||
| 158 | |||
| 159 | =head2 The 'unicode_strings' feature | ||
| 160 | |||
| 161 | C<use feature 'unicode_strings'> tells the compiler to use Unicode rules | ||
| 162 | in all string operations executed within its scope (unless they are also | ||
| 163 | within the scope of either C<use locale> or C<use bytes>). The same applies | ||
| 164 | to all regular expressions compiled within the scope, even if executed outside | ||
| 165 | it. It does not change the internal representation of strings, but only how | ||
| 166 | they are interpreted. | ||
| 167 | |||
| 168 | C<no feature 'unicode_strings'> tells the compiler to use the traditional | ||
| 169 | Perl rules wherein the native character set rules is used unless it is | ||
| 170 | clear to Perl that Unicode is desired. This can lead to some surprises | ||
| 171 | when the behavior suddenly changes. (See | ||
| 172 | L<perlunicode/The "Unicode Bug"> for details.) For this reason, if you are | ||
| 173 | potentially using Unicode in your program, the | ||
| 174 | C<use feature 'unicode_strings'> subpragma is B<strongly> recommended. | ||
| 175 | |||
| 176 | This feature is available starting with Perl 5.12; was almost fully | ||
| 177 | implemented in Perl 5.14; and extended in Perl 5.16 to cover C<quotemeta>; | ||
| 178 | and extended further in Perl 5.26 to cover L<the range | ||
| 179 | operator|perlop/Range Operators>. | ||
| 180 | |||
| 181 | =head2 The 'unicode_eval' and 'evalbytes' features | ||
| 182 | |||
| 183 | Together, these two features are intended to replace the legacy string | ||
| 184 | C<eval> function, which behaves problematically in some instances. They are | ||
| 185 | available starting with Perl 5.16, and are enabled by default by a | ||
| 186 | S<C<use 5.16>> or higher declaration. | ||
| 187 | |||
| 188 | C<unicode_eval> changes the behavior of plain string C<eval> to work more | ||
| 189 | consistently, especially in the Unicode world. Certain (mis)behaviors | ||
| 190 | couldn't be changed without breaking some things that had come to rely on | ||
| 191 | them, so the feature can be enabled and disabled. Details are at | ||
| 192 | L<perlfunc/Under the "unicode_eval" feature>. | ||
| 193 | |||
| 194 | C<evalbytes> is like string C<eval>, but operating on a byte stream that is | ||
| 195 | not UTF-8 encoded. Details are at L<perlfunc/evalbytes EXPR>. Without a | ||
| 196 | S<C<use feature 'evalbytes'>> nor a S<C<use v5.16>> (or higher) declaration in | ||
| 197 | the current scope, you can still access it by instead writing | ||
| 198 | C<CORE::evalbytes>. | ||
| 199 | |||
| 200 | =head2 The 'current_sub' feature | ||
| 201 | |||
| 202 | This provides the C<__SUB__> token that returns a reference to the current | ||
| 203 | subroutine or C<undef> outside of a subroutine. | ||
| 204 | |||
| 205 | This feature is available starting with Perl 5.16. | ||
| 206 | |||
| 207 | =head2 The 'array_base' feature | ||
| 208 | |||
| 209 | This feature supports the legacy C<$[> variable. See L<perlvar/$[> and | ||
| 210 | L<arybase>. It is on by default but disabled under C<use v5.16> (see | ||
| 211 | L</IMPLICIT LOADING>, below). | ||
| 212 | |||
| 213 | This feature is available under this name starting with Perl 5.16. In | ||
| 214 | previous versions, it was simply on all the time, and this pragma knew | ||
| 215 | nothing about it. | ||
| 216 | |||
| 217 | =head2 The 'fc' feature | ||
| 218 | |||
| 219 | C<use feature 'fc'> tells the compiler to enable the C<fc> function, | ||
| 220 | which implements Unicode casefolding. | ||
| 221 | |||
| 222 | See L<perlfunc/fc> for details. | ||
| 223 | |||
| 224 | This feature is available from Perl 5.16 onwards. | ||
| 225 | |||
| 226 | =head2 The 'lexical_subs' feature | ||
| 227 | |||
| 228 | In Perl versions prior to 5.26, this feature enabled | ||
| 229 | declaration of subroutines via C<my sub foo>, C<state sub foo> | ||
| 230 | and C<our sub foo> syntax. See L<perlsub/Lexical Subroutines> for details. | ||
| 231 | |||
| 232 | This feature is available from Perl 5.18 onwards. From Perl 5.18 to 5.24, | ||
| 233 | it was classed as experimental, and Perl emitted a warning for its | ||
| 234 | usage, except when explicitly disabled: | ||
| 235 | |||
| 236 | no warnings "experimental::lexical_subs"; | ||
| 237 | |||
| 238 | As of Perl 5.26, use of this feature no longer triggers a warning, though | ||
| 239 | the C<experimental::lexical_subs> warning category still exists (for | ||
| 240 | compatibility with code that disables it). In addition, this syntax is | ||
| 241 | not only no longer experimental, but it is enabled for all Perl code, | ||
| 242 | regardless of what feature declarations are in scope. | ||
| 243 | |||
| 244 | =head2 The 'postderef' and 'postderef_qq' features | ||
| 245 | |||
| 246 | The 'postderef_qq' feature extends the applicability of L<postfix | ||
| 247 | dereference syntax|perlref/Postfix Dereference Syntax> so that postfix array | ||
| 248 | and scalar dereference are available in double-quotish interpolations. For | ||
| 249 | example, it makes the following two statements equivalent: | ||
| 250 | |||
| 251 | my $s = "[@{ $h->{a} }]"; | ||
| 252 | my $s = "[$h->{a}->@*]"; | ||
| 253 | |||
| 254 | This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it | ||
| 255 | was classed as experimental, and Perl emitted a warning for its | ||
| 256 | usage, except when explicitly disabled: | ||
| 257 | |||
| 258 | no warnings "experimental::postderef"; | ||
| 259 | |||
| 260 | As of Perl 5.24, use of this feature no longer triggers a warning, though | ||
| 261 | the C<experimental::postderef> warning category still exists (for | ||
| 262 | compatibility with code that disables it). | ||
| 263 | |||
| 264 | The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable | ||
| 265 | postfix dereference syntax outside double-quotish interpolations. In those | ||
| 266 | versions, using it triggered the C<experimental::postderef> warning in the | ||
| 267 | same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is | ||
| 268 | not only no longer experimental, but it is enabled for all Perl code, | ||
| 269 | regardless of what feature declarations are in scope. | ||
| 270 | |||
| 271 | =head2 The 'signatures' feature | ||
| 272 | |||
| 273 | B<WARNING>: This feature is still experimental and the implementation may | ||
| 274 | change in future versions of Perl. For this reason, Perl will | ||
| 275 | warn when you use the feature, unless you have explicitly disabled the | ||
| 276 | warning: | ||
| 277 | |||
| 278 | no warnings "experimental::signatures"; | ||
| 279 | |||
| 280 | This enables unpacking of subroutine arguments into lexical variables | ||
| 281 | by syntax such as | ||
| 282 | |||
| 283 | sub foo ($left, $right) { | ||
| 284 | return $left + $right; | ||
| 285 | } | ||
| 286 | |||
| 287 | See L<perlsub/Signatures> for details. | ||
| 288 | |||
| 289 | This feature is available from Perl 5.20 onwards. | ||
| 290 | |||
| 291 | =head2 The 'refaliasing' feature | ||
| 292 | |||
| 293 | B<WARNING>: This feature is still experimental and the implementation may | ||
| 294 | change in future versions of Perl. For this reason, Perl will | ||
| 295 | warn when you use the feature, unless you have explicitly disabled the | ||
| 296 | warning: | ||
| 297 | |||
| 298 | no warnings "experimental::refaliasing"; | ||
| 299 | |||
| 300 | This enables aliasing via assignment to references: | ||
| 301 | |||
| 302 | \$a = \$b; # $a and $b now point to the same scalar | ||
| 303 | \@a = \@b; # to the same array | ||
| 304 | \%a = \%b; | ||
| 305 | \&a = \&b; | ||
| 306 | foreach \%hash (@array_of_hash_refs) { | ||
| 307 | ... | ||
| 308 | } | ||
| 309 | |||
| 310 | See L<perlref/Assigning to References> for details. | ||
| 311 | |||
| 312 | This feature is available from Perl 5.22 onwards. | ||
| 313 | |||
| 314 | =head2 The 'bitwise' feature | ||
| 315 | |||
| 316 | B<WARNING>: This feature is still experimental and the implementation may | ||
| 317 | change in future versions of Perl. For this reason, Perl will | ||
| 318 | warn when you use the feature, unless you have explicitly disabled the | ||
| 319 | warning: | ||
| 320 | |||
| 321 | no warnings "experimental::bitwise"; | ||
| 322 | |||
| 323 | This makes the four standard bitwise operators (C<& | ^ ~>) treat their | ||
| 324 | operands consistently as numbers, and introduces four new dotted operators | ||
| 325 | (C<&. |. ^. ~.>) that treat their operands consistently as strings. The | ||
| 326 | same applies to the assignment variants (C<&= |= ^= &.= |.= ^.=>). | ||
| 327 | |||
| 328 | See L<perlop/Bitwise String Operators> for details. | ||
| 329 | |||
| 330 | This feature is available from Perl 5.22 onwards. | ||
| 331 | |||
| 332 | =head2 The 'declared_refs' feature | ||
| 333 | |||
| 334 | B<WARNING>: This feature is still experimental and the implementation may | ||
| 335 | change in future versions of Perl. For this reason, Perl will | ||
| 336 | warn when you use the feature, unless you have explicitly disabled the | ||
| 337 | warning: | ||
| 338 | |||
| 339 | no warnings "experimental::declared_refs"; | ||
| 340 | |||
| 341 | This allows a reference to a variable to be declared with C<my>, C<state>, | ||
| 342 | our C<our>, or localized with C<local>. It is intended mainly for use in | ||
| 343 | conjunction with the "refaliasing" feature. See L<perlref/Declaring a | ||
| 344 | Reference to a Variable> for examples. | ||
| 345 | |||
| 346 | This feature is available from Perl 5.26 onwards. | ||
| 347 | |||
| 348 | =head1 FEATURE BUNDLES | ||
| 349 | |||
| 350 | It's possible to load multiple features together, using | ||
| 351 | a I<feature bundle>. The name of a feature bundle is prefixed with | ||
| 352 | a colon, to distinguish it from an actual feature. | ||
| 353 | |||
| 354 | use feature ":5.10"; | ||
| 355 | |||
| 356 | The following feature bundles are available: | ||
| 357 | |||
| 358 | bundle features included | ||
| 359 | --------- ----------------- | ||
| 360 | :default array_base | ||
| 361 | |||
| 362 | :5.10 say state switch array_base | ||
| 363 | |||
| 364 | :5.12 say state switch unicode_strings array_base | ||
| 365 | |||
| 366 | :5.14 say state switch unicode_strings array_base | ||
| 367 | |||
| 368 | :5.16 say state switch unicode_strings | ||
| 369 | unicode_eval evalbytes current_sub fc | ||
| 370 | |||
| 371 | :5.18 say state switch unicode_strings | ||
| 372 | unicode_eval evalbytes current_sub fc | ||
| 373 | |||
| 374 | :5.20 say state switch unicode_strings | ||
| 375 | unicode_eval evalbytes current_sub fc | ||
| 376 | |||
| 377 | :5.22 say state switch unicode_strings | ||
| 378 | unicode_eval evalbytes current_sub fc | ||
| 379 | |||
| 380 | :5.24 say state switch unicode_strings | ||
| 381 | unicode_eval evalbytes current_sub fc | ||
| 382 | postderef_qq | ||
| 383 | |||
| 384 | :5.26 say state switch unicode_strings | ||
| 385 | unicode_eval evalbytes current_sub fc | ||
| 386 | postderef_qq | ||
| 387 | |||
| 388 | The C<:default> bundle represents the feature set that is enabled before | ||
| 389 | any C<use feature> or C<no feature> declaration. | ||
| 390 | |||
| 391 | Specifying sub-versions such as the C<0> in C<5.14.0> in feature bundles has | ||
| 392 | no effect. Feature bundles are guaranteed to be the same for all sub-versions. | ||
| 393 | |||
| 394 | use feature ":5.14.0"; # same as ":5.14" | ||
| 395 | use feature ":5.14.1"; # same as ":5.14" | ||
| 396 | |||
| 397 | =head1 IMPLICIT LOADING | ||
| 398 | |||
| 399 | Instead of loading feature bundles by name, it is easier to let Perl do | ||
| 400 | implicit loading of a feature bundle for you. | ||
| 401 | |||
| 402 | There are two ways to load the C<feature> pragma implicitly: | ||
| 403 | |||
| 404 | =over 4 | ||
| 405 | |||
| 406 | =item * | ||
| 407 | |||
| 408 | By using the C<-E> switch on the Perl command-line instead of C<-e>. | ||
| 409 | That will enable the feature bundle for that version of Perl in the | ||
| 410 | main compilation unit (that is, the one-liner that follows C<-E>). | ||
| 411 | |||
| 412 | =item * | ||
| 413 | |||
| 414 | By explicitly requiring a minimum Perl version number for your program, with | ||
| 415 | the C<use VERSION> construct. That is, | ||
| 416 | |||
| 417 | use v5.10.0; | ||
| 418 | |||
| 419 | will do an implicit | ||
| 420 | |||
| 421 | no feature ':all'; | ||
| 422 | use feature ':5.10'; | ||
| 423 | |||
| 424 | and so on. Note how the trailing sub-version | ||
| 425 | is automatically stripped from the | ||
| 426 | version. | ||
| 427 | |||
| 428 | But to avoid portability warnings (see L<perlfunc/use>), you may prefer: | ||
| 429 | |||
| 430 | use 5.010; | ||
| 431 | |||
| 432 | with the same effect. | ||
| 433 | |||
| 434 | If the required version is older than Perl 5.10, the ":default" feature | ||
| 435 | bundle is automatically loaded instead. | ||
| 436 | |||
| 437 | =back | ||
| 438 | |||
| 439 | =cut | ||
| 440 | |||
| 441 | sub import { | ||
| 442 | shift; | ||
| 443 | |||
| 444 | if (!@_) { | ||
| 445 | croak("No features specified"); | ||
| 446 | } | ||
| 447 | |||
| 448 | __common(1, @_); | ||
| 449 | } | ||
| 450 | |||
| 451 | sub unimport { | ||
| 452 | shift; | ||
| 453 | |||
| 454 | # A bare C<no feature> should reset to the default bundle | ||
| 455 | if (!@_) { | ||
| 456 | $^H &= ~($hint_uni8bit|$hint_mask); | ||
| 457 | return; | ||
| 458 | } | ||
| 459 | |||
| 460 | __common(0, @_); | ||
| 461 | } | ||
| 462 | |||
| 463 | |||
| 464 | sub __common { | ||
| 465 | my $import = shift; | ||
| 466 | my $bundle_number = $^H & $hint_mask; | ||
| 467 | my $features = $bundle_number != $hint_mask | ||
| 468 | && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}; | ||
| 469 | if ($features) { | ||
| 470 | # Features are enabled implicitly via bundle hints. | ||
| 471 | # Delete any keys that may be left over from last time. | ||
| 472 | delete @^H{ values(%feature) }; | ||
| 473 | $^H |= $hint_mask; | ||
| 474 | for (@$features) { | ||
| 475 | $^H{$feature{$_}} = 1; | ||
| 476 | $^H |= $hint_uni8bit if $_ eq 'unicode_strings'; | ||
| 477 | } | ||
| 478 | } | ||
| 479 | while (@_) { | ||
| 480 | my $name = shift; | ||
| 481 | if (substr($name, 0, 1) eq ":") { | ||
| 482 | my $v = substr($name, 1); | ||
| 483 | if (!exists $feature_bundle{$v}) { | ||
| 484 | $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/; | ||
| 485 | if (!exists $feature_bundle{$v}) { | ||
| 486 | unknown_feature_bundle(substr($name, 1)); | ||
| 487 | } | ||
| 488 | } | ||
| 489 | unshift @_, @{$feature_bundle{$v}}; | ||
| 490 | next; | ||
| 491 | } | ||
| 492 | if (!exists $feature{$name}) { | ||
| 493 | if (exists $noops{$name}) { | ||
| 494 | next; | ||
| 495 | } | ||
| 496 | unknown_feature($name); | ||
| 497 | } | ||
| 498 | if ($import) { | ||
| 499 | $^H{$feature{$name}} = 1; | ||
| 500 | $^H |= $hint_uni8bit if $name eq 'unicode_strings'; | ||
| 501 | } else { | ||
| 502 | delete $^H{$feature{$name}}; | ||
| 503 | $^H &= ~ $hint_uni8bit if $name eq 'unicode_strings'; | ||
| 504 | } | ||
| 505 | } | ||
| 506 | } | ||
| 507 | |||
| 508 | sub unknown_feature { | ||
| 509 | my $feature = shift; | ||
| 510 | croak(sprintf('Feature "%s" is not supported by Perl %vd', | ||
| 511 | $feature, $^V)); | ||
| 512 | } | ||
| 513 | |||
| 514 | sub unknown_feature_bundle { | ||
| 515 | my $feature = shift; | ||
| 516 | croak(sprintf('Feature bundle "%s" is not supported by Perl %vd', | ||
| 517 | $feature, $^V)); | ||
| 518 | } | ||
| 519 | |||
| 520 | sub croak { | ||
| 521 | require Carp; | ||
| 522 | Carp::croak(@_); | ||
| 523 | } | ||
| 524 | |||
| 525 | 1; | ||
| 526 | |||
| 527 | # ex: set ro: |