Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\feature.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>feature - Perl pragma to enable new syntactic features</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> feature - Perl pragma to enable new syntactic features</span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <ul> <li><a href="#lexical_effect">Lexical effect</a></li> <li><a href="#no_feature"><code>no feature</code></a></li> <li><a href="#the__switch__feature">The 'switch' feature</a></li> <li><a href="#the__say__feature">The 'say' feature</a></li> <li><a href="#the__state__feature">the 'state' feature</a></li> </ul> <li><a href="#feature_bundles">FEATURE BUNDLES</a></li> <li><a href="#implicit_loading">IMPLICIT LOADING</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>feature - Perl pragma to enable new syntactic features</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use feature qw(switch say); given ($foo) { when (1) { say "\$foo == 1" } when ([2,3]) { say "\$foo == 2 || \$foo == 3" } when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" } when ($_ > 100) { say "\$foo > 100" } default { say "None of the above" } }</pre> <pre> use feature ':5.10'; # loads all features available in perl 5.10</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>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 can be enabled by <code>use feature 'foo'</code>, and will be parsed only when the appropriate feature pragma is in scope.</p> <p> </p> <h2><a name="lexical_effect">Lexical effect</a></h2> <p>Like other pragmas (<code>use strict</code>, for example), features have a lexical effect. <code>use feature qw(foo)</code> will only make the feature "foo" available from that point to the end of the enclosing block.</p> <pre> { use feature 'say'; say "say is available here"; } print "But not here.\n";</pre> <p> </p> <h2><a name="no_feature"><code>no feature</code></a></h2> <p>Features can also be turned off by using <code>no feature "foo"</code>. This too has lexical effect.</p> <pre> use feature 'say'; say "say is available here"; { no feature 'say'; print "But not here.\n"; } say "Yet it is here.";</pre> <p><code>no feature</code> with no features specified will turn off all features.</p> <p> </p> <h2><a name="the__switch__feature">The 'switch' feature</a></h2> <p><code>use feature 'switch'</code> tells the compiler to enable the Perl 6 given/when construct.</p> <p>See <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlsyn.html#switch_statements">Switch statements in the perlsyn manpage</a> for details.</p> <p> </p> <h2><a name="the__say__feature">The 'say' feature</a></h2> <p><code>use feature 'say'</code> tells the compiler to enable the Perl 6 <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#say"><code>say</code></a> function.</p> <p>See <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#say">say in the perlfunc manpage</a> for details.</p> <p> </p> <h2><a name="the__state__feature">the 'state' feature</a></h2> <p><code>use feature 'state'</code> tells the compiler to enable <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#state"><code>state</code></a> variables.</p> <p>See <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlsub.html#persistent_private_variables">Persistent Private Variables in the perlsub manpage</a> for details.</p> <p> </p> <hr /> <h1><a name="feature_bundles">FEATURE BUNDLES</a></h1> <p>It's possible to load a whole slew of features in one go, using a <em>feature bundle</em>. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature. At present, the only feature bundles are <code>use feature ":5.10"</code> and <code>use feature ":5.10.0"</code>, which both are equivalent to <code>use feature qw(switch say state)</code>.</p> <p>In the forthcoming 5.10.X perl releases, <code>use feature ":5.10"</code> will be equivalent to the latest <code>use feature ":5.10.X"</code>.</p> <p> </p> <hr /> <h1><a name="implicit_loading">IMPLICIT LOADING</a></h1> <p>There are two ways to load the <code>feature</code> pragma implicitly :</p> <ul> <li> <p>By using the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlguts.html#e"><code>-E</code></a> switch on the command-line instead of <code>-e</code>. It enables all available features in the main compilation unit (that is, the one-liner.)</p> </li> <li> <p>By requiring explicitly a minimal Perl version number for your program, with the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#use"><code>use VERSION</code></a> construct, and when the version is higher than or equal to 5.10.0. That is,</p> <pre> use 5.10.0;</pre> <p>will do an implicit</p> <pre> use feature ':5.10.0';</pre> <p>and so on.</p> <p>But to avoid portability warnings (see <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#use">use in the perlfunc manpage</a>), you may prefer:</p> <pre> use 5.010;</pre> <p>with the same effect.</p> </li> </ul> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> feature - Perl pragma to enable new syntactic features</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de