Current Path : /usr/opt/perl530/man/man3/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/perl530/man/man3/feature.3 |
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "feature 3" .TH feature 3 "2019-10-24" "perl v5.30.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" feature \- Perl pragma to enable new features .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 8 \& use feature qw(say switch); \& given ($foo) { \& when (1) { say "\e$foo == 1" } \& when ([2,3]) { say "\e$foo == 2 || \e$foo == 3" } \& when (/^a[bc]d$/) { say "\e$foo eq \*(Aqabd\*(Aq || \e$foo eq \*(Aqacd\*(Aq" } \& when ($_ > 100) { say "\e$foo > 100" } \& default { say "None of the above" } \& } \& \& use feature \*(Aq:5.10\*(Aq; # loads all features available in perl 5.10 \& \& use v5.10; # implicitly loads :5.10 feature bundle .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" It is usually impossible to add new syntax to Perl without breaking some existing programs. This pragma provides a way to minimize that risk. New syntactic constructs, or new semantic meanings to older constructs, can be enabled by \f(CW\*(C`use feature \*(Aqfoo\*(Aq\*(C'\fR, and will be parsed only when the appropriate feature pragma is in scope. (Nevertheless, the \&\f(CW\*(C`CORE::\*(C'\fR prefix provides access to all Perl keywords, regardless of this pragma.) .SS "Lexical effect" .IX Subsection "Lexical effect" Like other pragmas (\f(CW\*(C`use strict\*(C'\fR, for example), features have a lexical effect. \f(CW\*(C`use feature qw(foo)\*(C'\fR will only make the feature \*(L"foo\*(R" available from that point to the end of the enclosing block. .PP .Vb 5 \& { \& use feature \*(Aqsay\*(Aq; \& say "say is available here"; \& } \& print "But not here.\en"; .Ve .ie n .SS """no feature""" .el .SS "\f(CWno feature\fP" .IX Subsection "no feature" Features can also be turned off by using \f(CW\*(C`no feature "foo"\*(C'\fR. This too has lexical effect. .PP .Vb 7 \& use feature \*(Aqsay\*(Aq; \& say "say is available here"; \& { \& no feature \*(Aqsay\*(Aq; \& print "But not here.\en"; \& } \& say "Yet it is here."; .Ve .PP \&\f(CW\*(C`no feature\*(C'\fR with no features specified will reset to the default group. To disable \fIall\fR features (an unusual request!) use \f(CW\*(C`no feature \*(Aq:all\*(Aq\*(C'\fR. .SH "AVAILABLE FEATURES" .IX Header "AVAILABLE FEATURES" .SS "The 'say' feature" .IX Subsection "The 'say' feature" \&\f(CW\*(C`use feature \*(Aqsay\*(Aq\*(C'\fR tells the compiler to enable the Perl 6 style \&\f(CW\*(C`say\*(C'\fR function. .PP See \*(L"say\*(R" in perlfunc for details. .PP This feature is available starting with Perl 5.10. .SS "The 'state' feature" .IX Subsection "The 'state' feature" \&\f(CW\*(C`use feature \*(Aqstate\*(Aq\*(C'\fR tells the compiler to enable \f(CW\*(C`state\*(C'\fR variables. .PP See \*(L"Persistent Private Variables\*(R" in perlsub for details. .PP This feature is available starting with Perl 5.10. .SS "The 'switch' feature" .IX Subsection "The 'switch' feature" \&\fB\s-1WARNING\s0\fR: Because the smartmatch operator is experimental, Perl will warn when you use this feature, unless you have explicitly disabled the warning: .PP .Vb 1 \& no warnings "experimental::smartmatch"; .Ve .PP \&\f(CW\*(C`use feature \*(Aqswitch\*(Aq\*(C'\fR tells the compiler to enable the Perl 6 given/when construct. .PP See \*(L"Switch Statements\*(R" in perlsyn for details. .PP This feature is available starting with Perl 5.10. .SS "The 'unicode_strings' feature" .IX Subsection "The 'unicode_strings' feature" \&\f(CW\*(C`use feature \*(Aqunicode_strings\*(Aq\*(C'\fR tells the compiler to use Unicode rules in all string operations executed within its scope (unless they are also within the scope of either \f(CW\*(C`use locale\*(C'\fR or \f(CW\*(C`use bytes\*(C'\fR). The same applies to all regular expressions compiled within the scope, even if executed outside it. It does not change the internal representation of strings, but only how they are interpreted. .PP \&\f(CW\*(C`no feature \*(Aqunicode_strings\*(Aq\*(C'\fR tells the compiler to use the traditional Perl rules wherein the native character set rules is used unless it is clear to Perl that Unicode is desired. This can lead to some surprises when the behavior suddenly changes. (See \&\*(L"The \*(R"Unicode Bug"" in perlunicode for details.) For this reason, if you are potentially using Unicode in your program, the \&\f(CW\*(C`use feature \*(Aqunicode_strings\*(Aq\*(C'\fR subpragma is \fBstrongly\fR recommended. .PP This feature is available starting with Perl 5.12; was almost fully implemented in Perl 5.14; and extended in Perl 5.16 to cover \f(CW\*(C`quotemeta\*(C'\fR; was extended further in Perl 5.26 to cover the range operator; and was extended again in Perl 5.28 to cover special-cased whitespace splitting. .SS "The 'unicode_eval' and 'evalbytes' features" .IX Subsection "The 'unicode_eval' and 'evalbytes' features" Together, these two features are intended to replace the legacy string \&\f(CW\*(C`eval\*(C'\fR function, which behaves problematically in some instances. They are available starting with Perl 5.16, and are enabled by default by a \&\f(CW\*(C`use\ 5.16\*(C'\fR or higher declaration. .PP \&\f(CW\*(C`unicode_eval\*(C'\fR changes the behavior of plain string \f(CW\*(C`eval\*(C'\fR to work more consistently, especially in the Unicode world. Certain (mis)behaviors couldn't be changed without breaking some things that had come to rely on them, so the feature can be enabled and disabled. Details are at \&\*(L"Under the \*(R"unicode_eval\*(L" feature\*(R" in perlfunc. .PP \&\f(CW\*(C`evalbytes\*(C'\fR is like string \f(CW\*(C`eval\*(C'\fR, but operating on a byte stream that is not \s-1UTF\-8\s0 encoded. Details are at \*(L"evalbytes \s-1EXPR\*(R"\s0 in perlfunc. Without a \&\f(CW\*(C`use\ feature\ \*(Aqevalbytes\*(Aq\*(C'\fR nor a \f(CW\*(C`use\ v5.16\*(C'\fR (or higher) declaration in the current scope, you can still access it by instead writing \&\f(CW\*(C`CORE::evalbytes\*(C'\fR. .SS "The 'current_sub' feature" .IX Subsection "The 'current_sub' feature" This provides the \f(CW\*(C`_\|_SUB_\|_\*(C'\fR token that returns a reference to the current subroutine or \f(CW\*(C`undef\*(C'\fR outside of a subroutine. .PP This feature is available starting with Perl 5.16. .SS "The 'array_base' feature" .IX Subsection "The 'array_base' feature" This feature supported the legacy \f(CW$[\fR variable. See \*(L"$[\*(R" in perlvar. It was on by default but disabled under \f(CW\*(C`use v5.16\*(C'\fR (see \&\*(L"\s-1IMPLICIT LOADING\*(R"\s0, below) and unavailable since perl 5.30. .PP This feature is available under this name starting with Perl 5.16. In previous versions, it was simply on all the time, and this pragma knew nothing about it. .SS "The 'fc' feature" .IX Subsection "The 'fc' feature" \&\f(CW\*(C`use feature \*(Aqfc\*(Aq\*(C'\fR tells the compiler to enable the \f(CW\*(C`fc\*(C'\fR function, which implements Unicode casefolding. .PP See \*(L"fc\*(R" in perlfunc for details. .PP This feature is available from Perl 5.16 onwards. .SS "The 'lexical_subs' feature" .IX Subsection "The 'lexical_subs' feature" In Perl versions prior to 5.26, this feature enabled declaration of subroutines via \f(CW\*(C`my sub foo\*(C'\fR, \f(CW\*(C`state sub foo\*(C'\fR and \f(CW\*(C`our sub foo\*(C'\fR syntax. See \*(L"Lexical Subroutines\*(R" in perlsub for details. .PP This feature is available from Perl 5.18 onwards. From Perl 5.18 to 5.24, it was classed as experimental, and Perl emitted a warning for its usage, except when explicitly disabled: .PP .Vb 1 \& no warnings "experimental::lexical_subs"; .Ve .PP As of Perl 5.26, use of this feature no longer triggers a warning, though the \f(CW\*(C`experimental::lexical_subs\*(C'\fR warning category still exists (for compatibility with code that disables it). In addition, this syntax is not only no longer experimental, but it is enabled for all Perl code, regardless of what feature declarations are in scope. .SS "The 'postderef' and 'postderef_qq' features" .IX Subsection "The 'postderef' and 'postderef_qq' features" The 'postderef_qq' feature extends the applicability of postfix dereference syntax so that postfix array and scalar dereference are available in double-quotish interpolations. For example, it makes the following two statements equivalent: .PP .Vb 2 \& my $s = "[@{ $h\->{a} }]"; \& my $s = "[$h\->{a}\->@*]"; .Ve .PP This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it was classed as experimental, and Perl emitted a warning for its usage, except when explicitly disabled: .PP .Vb 1 \& no warnings "experimental::postderef"; .Ve .PP As of Perl 5.24, use of this feature no longer triggers a warning, though the \f(CW\*(C`experimental::postderef\*(C'\fR warning category still exists (for compatibility with code that disables it). .PP The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable postfix dereference syntax outside double-quotish interpolations. In those versions, using it triggered the \f(CW\*(C`experimental::postderef\*(C'\fR warning in the same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is not only no longer experimental, but it is enabled for all Perl code, regardless of what feature declarations are in scope. .SS "The 'signatures' feature" .IX Subsection "The 'signatures' feature" \&\fB\s-1WARNING\s0\fR: This feature is still experimental and the implementation may change in future versions of Perl. For this reason, Perl will warn when you use the feature, unless you have explicitly disabled the warning: .PP .Vb 1 \& no warnings "experimental::signatures"; .Ve .PP This enables unpacking of subroutine arguments into lexical variables by syntax such as .PP .Vb 3 \& sub foo ($left, $right) { \& return $left + $right; \& } .Ve .PP See \*(L"Signatures\*(R" in perlsub for details. .PP This feature is available from Perl 5.20 onwards. .SS "The 'refaliasing' feature" .IX Subsection "The 'refaliasing' feature" \&\fB\s-1WARNING\s0\fR: This feature is still experimental and the implementation may change in future versions of Perl. For this reason, Perl will warn when you use the feature, unless you have explicitly disabled the warning: .PP .Vb 1 \& no warnings "experimental::refaliasing"; .Ve .PP This enables aliasing via assignment to references: .PP .Vb 7 \& \e$a = \e$b; # $a and $b now point to the same scalar \& \e@a = \e@b; # to the same array \& \e%a = \e%b; \& \e&a = \e&b; \& foreach \e%hash (@array_of_hash_refs) { \& ... \& } .Ve .PP See \*(L"Assigning to References\*(R" in perlref for details. .PP This feature is available from Perl 5.22 onwards. .SS "The 'bitwise' feature" .IX Subsection "The 'bitwise' feature" This makes the four standard bitwise operators (\f(CW\*(C`& | ^ ~\*(C'\fR) treat their operands consistently as numbers, and introduces four new dotted operators (\f(CW\*(C`&. |. ^. ~.\*(C'\fR) that treat their operands consistently as strings. The same applies to the assignment variants (\f(CW\*(C`&= |= ^= &.= |.= ^.=\*(C'\fR). .PP See \*(L"Bitwise String Operators\*(R" in perlop for details. .PP This feature is available from Perl 5.22 onwards. Starting in Perl 5.28, \&\f(CW\*(C`use v5.28\*(C'\fR will enable the feature. Before 5.28, it was still experimental and would emit a warning in the \*(L"experimental::bitwise\*(R" category. .SS "The 'declared_refs' feature" .IX Subsection "The 'declared_refs' feature" \&\fB\s-1WARNING\s0\fR: This feature is still experimental and the implementation may change in future versions of Perl. For this reason, Perl will warn when you use the feature, unless you have explicitly disabled the warning: .PP .Vb 1 \& no warnings "experimental::declared_refs"; .Ve .PP This allows a reference to a variable to be declared with \f(CW\*(C`my\*(C'\fR, \f(CW\*(C`state\*(C'\fR, our \f(CW\*(C`our\*(C'\fR, or localized with \f(CW\*(C`local\*(C'\fR. It is intended mainly for use in conjunction with the \*(L"refaliasing\*(R" feature. See \*(L"Declaring a Reference to a Variable\*(R" in perlref for examples. .PP This feature is available from Perl 5.26 onwards. .SH "FEATURE BUNDLES" .IX Header "FEATURE BUNDLES" It's possible to load multiple features together, using a \fIfeature bundle\fR. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature. .PP .Vb 1 \& use feature ":5.10"; .Ve .PP The following feature bundles are available: .PP .Vb 3 \& bundle features included \& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& :default \& \& :5.10 say state switch \& \& :5.12 say state switch unicode_strings \& \& :5.14 say state switch unicode_strings \& \& :5.16 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& \& :5.18 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& \& :5.20 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& \& :5.22 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& \& :5.24 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& postderef_qq \& \& :5.26 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& postderef_qq \& \& :5.28 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& postderef_qq bitwise \& \& :5.30 say state switch unicode_strings \& unicode_eval evalbytes current_sub fc \& postderef_qq bitwise .Ve .PP The \f(CW\*(C`:default\*(C'\fR bundle represents the feature set that is enabled before any \f(CW\*(C`use feature\*(C'\fR or \f(CW\*(C`no feature\*(C'\fR declaration. .PP Specifying sub-versions such as the \f(CW0\fR in \f(CW5.14.0\fR in feature bundles has no effect. Feature bundles are guaranteed to be the same for all sub-versions. .PP .Vb 2 \& use feature ":5.14.0"; # same as ":5.14" \& use feature ":5.14.1"; # same as ":5.14" .Ve .SH "IMPLICIT LOADING" .IX Header "IMPLICIT LOADING" Instead of loading feature bundles by name, it is easier to let Perl do implicit loading of a feature bundle for you. .PP There are two ways to load the \f(CW\*(C`feature\*(C'\fR pragma implicitly: .IP "\(bu" 4 By using the \f(CW\*(C`\-E\*(C'\fR switch on the Perl command-line instead of \f(CW\*(C`\-e\*(C'\fR. That will enable the feature bundle for that version of Perl in the main compilation unit (that is, the one-liner that follows \f(CW\*(C`\-E\*(C'\fR). .IP "\(bu" 4 By explicitly requiring a minimum Perl version number for your program, with the \f(CW\*(C`use VERSION\*(C'\fR construct. That is, .Sp .Vb 1 \& use v5.10.0; .Ve .Sp will do an implicit .Sp .Vb 2 \& no feature \*(Aq:all\*(Aq; \& use feature \*(Aq:5.10\*(Aq; .Ve .Sp and so on. Note how the trailing sub-version is automatically stripped from the version. .Sp But to avoid portability warnings (see \*(L"use\*(R" in perlfunc), you may prefer: .Sp .Vb 1 \& use 5.010; .Ve .Sp with the same effect. .Sp If the required version is older than Perl 5.10, the \*(L":default\*(R" feature bundle is automatically loaded instead. .Sp Unlike \f(CW\*(C`use feature ":5.12"\*(C'\fR, saying \f(CW\*(C`use v5.12\*(C'\fR (or any higher version) also does the equivalent of \f(CW\*(C`use strict\*(C'\fR; see \*(L"use\*(R" in perlfunc for details.