CINXE.COM

Perl Documentation - Perldoc Browser

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Perl Documentation - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" /> <style> body { background: #f4f4f5; color: #020202; } .navbar-dark { background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%); background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%); background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0); background-repeat: repeat-x; } .navbar-dark .navbar-nav .nav-link, .navbar-dark .navbar-nav .nav-link:focus { color: #fff } .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 } #wrapperlicious { margin: 0 auto; font: 0.9em 'Helvetica Neue', Helvetica, sans-serif; font-weight: normal; line-height: 1.5em; margin: 0; padding: 0; } #wrapperlicious h1 { font-size: 1.5em } #wrapperlicious h2 { font-size: 1.3em } #wrapperlicious h3 { font-size: 1.1em } #wrapperlicious h4 { font-size: 0.9em } #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3, #wrapperlicious h4, #wrapperlicious dt { color: #020202; margin-top: 1em; margin-bottom: 1em; position: relative; font-weight: bold; } #wrapperlicious a { color: inherit; text-decoration: underline } #wrapperlicious #toc { text-decoration: none } #wrapperlicious a:hover { color: #2a2a2a } #wrapperlicious a img { border: 0 } #wrapperlicious :not(pre) > code { color: inherit; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; font: 0.9em Consolas, Menlo, Monaco, monospace; padding: 0.3em; } #wrapperlicious dd { margin: 0; margin-left: 2em; } #wrapperlicious dt { color: #2a2a2a; font-weight: bold; margin-left: 0.9em; } #wrapperlicious p { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious li > p { margin-bottom: 0; margin-top: 0; } #wrapperlicious pre { border: 1px solid #c1c1c1; border-radius: 3px; font: 100% Consolas, Menlo, Monaco, monospace; margin-bottom: 1em; margin-top: 1em; } #wrapperlicious pre > code { display: block; background-color: #f6f6f6; font: 0.9em Consolas, Menlo, Monaco, monospace; line-height: 1.5em; text-align: left; white-space: pre; padding: 1em; } #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious ul { list-style-type: square; } #wrapperlicious ul ul { margin-bottom: 0px; margin-top: 0px; } #footer { font-size: 0.8em; padding-top: 0.5em; text-align: center; } #more { display: inline; font-size: 0.8em; } #perldocdiv { background-color: #fff; border: 1px solid #c1c1c1; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; margin-left: auto; margin-right: auto; padding: 3em; padding-top: 1em; max-width: 960px; } #moduleversion { float: right } #wrapperlicious .leading-notice { font-style: italic; padding-left: 1em; margin-top: 1em; margin-bottom: 1em; } #wrapperlicious .permalink { display: none; left: -0.75em; position: absolute; padding-right: 0.25em; text-decoration: none; } #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink, #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink, #wrapperlicious dt:hover .permalink { display: block; } </style> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-KVNWBNT5FB'); gtag('config', 'UA-50555-3'); </script> </head> <body> <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <a class="navbar-brand" href="/">Perldoc Browser</a> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav mr-auto"> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.005</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.0/">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.2/">5.38.2</a> <a class="dropdown-item" href="/5.38.1/">5.38.1</a> <a class="dropdown-item" href="/5.38.0/">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/">5.36.3</a> <a class="dropdown-item" href="/5.36.2/">5.36.2</a> <a class="dropdown-item" href="/5.36.1/">5.36.1</a> <a class="dropdown-item" href="/5.36.0/">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/">5.34.3</a> <a class="dropdown-item" href="/5.34.2/">5.34.2</a> <a class="dropdown-item" href="/5.34.1/">5.34.1</a> <a class="dropdown-item" href="/5.34.0/">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/">5.32.1</a> <a class="dropdown-item" href="/5.32.0/">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/">5.30.3</a> <a class="dropdown-item" href="/5.30.2/">5.30.2</a> <a class="dropdown-item" href="/5.30.1/">5.30.1</a> <a class="dropdown-item" href="/5.30.0/">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/">5.28.3</a> <a class="dropdown-item" href="/5.28.2/">5.28.2</a> <a class="dropdown-item" href="/5.28.1/">5.28.1</a> <a class="dropdown-item" href="/5.28.0/">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/">5.26.3</a> <a class="dropdown-item" href="/5.26.2/">5.26.2</a> <a class="dropdown-item" href="/5.26.1/">5.26.1</a> <a class="dropdown-item" href="/5.26.0/">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/">5.24.4</a> <a class="dropdown-item" href="/5.24.3/">5.24.3</a> <a class="dropdown-item" href="/5.24.2/">5.24.2</a> <a class="dropdown-item" href="/5.24.1/">5.24.1</a> <a class="dropdown-item" href="/5.24.0/">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/">5.22.4</a> <a class="dropdown-item" href="/5.22.3/">5.22.3</a> <a class="dropdown-item" href="/5.22.2/">5.22.2</a> <a class="dropdown-item" href="/5.22.1/">5.22.1</a> <a class="dropdown-item" href="/5.22.0/">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/">5.20.3</a> <a class="dropdown-item" href="/5.20.2/">5.20.2</a> <a class="dropdown-item" href="/5.20.1/">5.20.1</a> <a class="dropdown-item" href="/5.20.0/">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/">5.18.4</a> <a class="dropdown-item" href="/5.18.3/">5.18.3</a> <a class="dropdown-item" href="/5.18.2/">5.18.2</a> <a class="dropdown-item" href="/5.18.1/">5.18.1</a> <a class="dropdown-item" href="/5.18.0/">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/">5.16.3</a> <a class="dropdown-item" href="/5.16.2/">5.16.2</a> <a class="dropdown-item" href="/5.16.1/">5.16.1</a> <a class="dropdown-item" href="/5.16.0/">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/">5.14.4</a> <a class="dropdown-item" href="/5.14.3/">5.14.3</a> <a class="dropdown-item" href="/5.14.2/">5.14.2</a> <a class="dropdown-item" href="/5.14.1/">5.14.1</a> <a class="dropdown-item" href="/5.14.0/">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/">5.12.5</a> <a class="dropdown-item" href="/5.12.4/">5.12.4</a> <a class="dropdown-item" href="/5.12.3/">5.12.3</a> <a class="dropdown-item" href="/5.12.2/">5.12.2</a> <a class="dropdown-item" href="/5.12.1/">5.12.1</a> <a class="dropdown-item" href="/5.12.0/">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/">5.10.1</a> <a class="dropdown-item" href="/5.10.0/">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/">5.8.9</a> <a class="dropdown-item" href="/5.8.8/">5.8.8</a> <a class="dropdown-item" href="/5.8.7/">5.8.7</a> <a class="dropdown-item" href="/5.8.6/">5.8.6</a> <a class="dropdown-item" href="/5.8.5/">5.8.5</a> <a class="dropdown-item" href="/5.8.4/">5.8.4</a> <a class="dropdown-item" href="/5.8.3/">5.8.3</a> <a class="dropdown-item" href="/5.8.2/">5.8.2</a> <a class="dropdown-item" href="/5.8.1/">5.8.1</a> <a class="dropdown-item" href="/5.8.0/">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/">5.6.2</a> <a class="dropdown-item" href="/5.6.1/">5.6.1</a> <a class="dropdown-item" href="/5.6.0/">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/">5.005_04</a> <a class="dropdown-item" href="/5.005_03/">5.005_03</a> <a class="dropdown-item" href="/5.005_02/">5.005_02</a> <a class="dropdown-item" href="/5.005_01/">5.005_01</a> <a class="dropdown-item active" href="/5.005/">5.005</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-dev"> <a class="dropdown-item" href="/blead/">blead</a> <a class="dropdown-item" href="/5.41.6/">5.41.6</a> <a class="dropdown-item" href="/5.41.5/">5.41.5</a> <a class="dropdown-item" href="/5.41.4/">5.41.4</a> <a class="dropdown-item" href="/5.41.3/">5.41.3</a> <a class="dropdown-item" href="/5.41.2/">5.41.2</a> <a class="dropdown-item" href="/5.41.1/">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.0-RC2/">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/">5.39.10</a> <a class="dropdown-item" href="/5.39.9/">5.39.9</a> <a class="dropdown-item" href="/5.39.8/">5.39.8</a> <a class="dropdown-item" href="/5.39.7/">5.39.7</a> <a class="dropdown-item" href="/5.39.6/">5.39.6</a> <a class="dropdown-item" href="/5.39.5/">5.39.5</a> <a class="dropdown-item" href="/5.39.4/">5.39.4</a> <a class="dropdown-item" href="/5.39.3/">5.39.3</a> <a class="dropdown-item" href="/5.39.2/">5.39.2</a> <a class="dropdown-item" href="/5.39.1/">5.39.1</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-nav"> <a class="dropdown-item" href="/5.005/perl">Perl</a> <a class="dropdown-item" href="/5.005/perlintro">Intro</a> <a class="dropdown-item" href="/5.005/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.005/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.005/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005/perlop">Operators</a> <a class="dropdown-item" href="/5.005/functions">Functions</a> <a class="dropdown-item" href="/5.005/variables">Variables</a> <a class="dropdown-item" href="/5.005/modules">Modules</a> <a class="dropdown-item" href="/5.005/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.005/perlcommunity">Community</a> <a class="dropdown-item" href="/5.005/perlhist">History</a> </div> </li> </ul> <ul class="navbar-nav"> <script> function set_expand (expand) { var perldocdiv = document.getElementById('perldocdiv'); var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width'); var expanded = (width == '' || width == 'none') ? true : false; if (expand === null) { expand = !expanded; } if ((expand && !expanded) || (!expand && expanded)) { perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px'); var button_classlist = document.getElementById('content-expand-button').classList; if (expand) { button_classlist.add('btn-light'); button_classlist.remove('btn-outline-light'); } else { button_classlist.add('btn-outline-light'); button_classlist.remove('btn-light'); } } return expand; } function toggle_expand () { var expand = set_expand(null); document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC'; } function read_expand () { return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { if (read_expand()) { set_expand(true); } }); } else if (read_expand()) { set_expand(true); } </script> <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-4" onclick="toggle_expand()">Expand</button> </ul> <form class="form-inline" method="get" action="/5.005/search"> <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search" value=""> </form> </div> </nav> <div id="wrapperlicious" class="container-fluid"> <div id="perldocdiv"> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.005. <a href="/">View the latest version</a> </div> <h1 id="Perl-5.005-Documentation"><a class="permalink" href="#Perl-5.005-Documentation">#</a><a id="Perl"></a>Perl 5.005 Documentation</h1> <p>For ease of access, the Perl manual has been split up into a number of sections:</p> <pre><code class="nohighlight">perl Perl overview (this section) <a href="/5.005/perldelta">perldelta</a> Perl changes since previous version <a href="/5.005/perlfaq">perlfaq</a> Perl frequently asked questions <a href="/5.005/perltoc">perltoc</a> Perl documentation table of contents <a href="/5.005/perldata">perldata</a> Perl data structures <a href="/5.005/perlsyn">perlsyn</a> Perl syntax <a href="/5.005/perlop">perlop</a> Perl operators and precedence <a href="/5.005/perlre">perlre</a> Perl regular expressions <a href="/5.005/perlrun">perlrun</a> Perl execution and options <a href="/5.005/perlfunc">perlfunc</a> Perl builtin functions <a href="/5.005/perlvar">perlvar</a> Perl predefined variables <a href="/5.005/perlsub">perlsub</a> Perl subroutines <a href="/5.005/perlmod">perlmod</a> Perl modules: how they work <a href="/5.005/perlmodlib">perlmodlib</a> Perl modules: how to write and use <a href="/5.005/perlmodinstall">perlmodinstall</a> Perl modules: how to install from CPAN <a href="/5.005/perlform">perlform</a> Perl formats <a href="/5.005/perllocale">perllocale</a> Perl locale support <a href="/5.005/perlref">perlref</a> Perl references <a href="/5.005/perldsc">perldsc</a> Perl data structures intro <a href="/5.005/perllol">perllol</a> Perl data structures: lists of lists <a href="/5.005/perltoot">perltoot</a> Perl OO tutorial <a href="/5.005/perlobj">perlobj</a> Perl objects <a href="/5.005/perltie">perltie</a> Perl objects hidden behind simple variables <a href="/5.005/perlbot">perlbot</a> Perl OO tricks and examples <a href="/5.005/perlipc">perlipc</a> Perl interprocess communication <a href="/5.005/perldebug">perldebug</a> Perl debugging <a href="/5.005/perldiag">perldiag</a> Perl diagnostic messages <a href="/5.005/perlsec">perlsec</a> Perl security <a href="/5.005/perltrap">perltrap</a> Perl traps for the unwary <a href="/5.005/perlport">perlport</a> Perl portability guide <a href="/5.005/perlstyle">perlstyle</a> Perl style guide <a href="/5.005/perlpod">perlpod</a> Perl plain old documentation <a href="/5.005/perlbook">perlbook</a> Perl book information <a href="/5.005/perlembed">perlembed</a> Perl ways to embed perl in your C or C++ application <a href="/5.005/perlapio">perlapio</a> Perl internal IO abstraction interface <a href="/5.005/perlxs">perlxs</a> Perl XS application programming interface <a href="/5.005/perlxstut">perlxstut</a> Perl XS tutorial <a href="/5.005/perlguts">perlguts</a> Perl internal functions for those doing extensions <a href="/5.005/perlcall">perlcall</a> Perl calling conventions from C <a href="/5.005/perlhist">perlhist</a> Perl history records</code></pre> <p>(If you&#39;re intending to read these straight through for the first time, the suggested order will tend to reduce the number of forward references.)</p> <p>By default, all of the above manpages are installed in the <i>/usr/local/man/</i> directory.</p> <p>Extensive additional documentation for Perl modules is available. The default configuration for perl will place this additional documentation in the <i>/usr/local/lib/perl5/man</i> directory (or else in the <i>man</i> subdirectory of the Perl library directory). Some of this additional documentation is distributed standard with Perl, but you&#39;ll also find documentation for third-party modules there.</p> <p>You should be able to view Perl&#39;s documentation with your man(1) program by including the proper directories in the appropriate start-up files, or in the MANPATH environment variable. To find out where the configuration has installed the manpages, type:</p> <pre><code class="nohighlight">perl -V:man.dir</code></pre> <p>If the directories have a common stem, such as <i>/usr/local/man/man1</i> and <i>/usr/local/man/man3</i>, you need only to add that stem (<i>/usr/local/man</i>) to your man(1) configuration files or your MANPATH environment variable. If they do not share a stem, you&#39;ll have to add both stems.</p> <p>If that doesn&#39;t work for some reason, you can still use the supplied <i>perldoc</i> script to view module information. You might also look into getting a replacement man program.</p> <p>If something strange has gone wrong with your program and you&#39;re not sure where you should look for help, try the <b>-w</b> switch first. It will often point out exactly where the trouble is.</p> <p><i>Full perl(1) documentation: <a href="/5.005/perl">perl</a></i></p> <h2 id="Reference-Lists"><a class="permalink" href="#Reference-Lists">#</a><a id="Reference"></a>Reference Lists</h2> <ul> <li><p><a href="/5.005/perlop">Operators</a></p> </li> <li><p><a href="/5.005/functions">Functions</a></p> </li> <li><p><a href="/5.005/variables">Variables</a></p> </li> <li><p><a href="/5.005/modules">Modules</a></p> </li> <li><p><a href="/5.005/perlutil">Utilities</a></p> </li> </ul> <h2 id="More-Info"><a class="permalink" href="#More-Info">#</a><a id="More"></a>More Info</h2> <ul> <li><p><a href="/5.005/perldelta">Perl 5.005 Release Notes</a></p> </li> <li><p><a href="/5.005/perlcommunity">Community</a></p> </li> <li><p><a href="/5.005/perlfaq">FAQs</a></p> </li> </ul> <h2 id="About-Perl"><a class="permalink" href="#About-Perl">#</a><a id="About"></a>About Perl</h2> <p>Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It&#39;s also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).</p> <p>Perl combines (in the author&#39;s opinion, anyway) some of the best features of C, <b>sed</b>, <b>awk</b>, and <b>sh</b>, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of <b>csh</b>, Pascal, and even BASIC-PLUS.) Expression syntax corresponds quite closely to C expression syntax. Unlike most Unix utilities, Perl does not arbitrarily limit the size of your data--if you&#39;ve got the memory, Perl can slurp in your whole file as a single string. Recursion is of unlimited depth. And the tables used by hashes (previously called &quot;associative arrays&quot;) grow as necessary to prevent degraded performance. Perl uses sophisticated pattern matching techniques to scan large amounts of data very quickly. Although optimized for scanning text, Perl can also deal with binary data, and can make dbm files look like hashes. Setuid Perl scripts are safer than C programs through a dataflow tracing mechanism which prevents many stupid security holes.</p> <p>If you have a problem that would ordinarily use <b>sed</b> or <b>awk</b> or <b>sh</b>, but it exceeds their capabilities or must run a little faster, and you don&#39;t want to write the silly thing in C, then Perl may be for you. There are also translators to turn your <b>sed</b> and <b>awk</b> scripts into Perl scripts.</p> <p>But wait, there&#39;s more...</p> <p>Perl version 5 is nearly a complete rewrite, and provides the following additional benefits:</p> <ul> <li><p>Many usability enhancements</p> <p>It is now possible to write much more readable Perl code (even within regular expressions). Formerly cryptic variable names can be replaced by mnemonic identifiers. Error messages are more informative, and the optional warnings will catch many of the mistakes a novice might make. This cannot be stressed enough. Whenever you get mysterious behavior, try the <b>-w</b> switch!!! Whenever you don&#39;t get mysterious behavior, try using <b>-w</b> anyway.</p> </li> <li><p>Simplified grammar</p> <p>The new yacc grammar is one half the size of the old one. Many of the arbitrary grammar rules have been regularized. The number of reserved words has been cut by 2/3. Despite this, nearly all old Perl scripts will continue to work unchanged.</p> </li> <li><p>Lexical scoping</p> <p>Perl variables may now be declared within a lexical scope, like &quot;auto&quot; variables in C. Not only is this more efficient, but it contributes to better privacy for &quot;programming in the large&quot;. Anonymous subroutines exhibit deep binding of lexical variables (closures).</p> </li> <li><p>Arbitrarily nested data structures</p> <p>Any scalar value, including any array element, may now contain a reference to any other variable or subroutine. You can easily create anonymous variables and subroutines. Perl manages your reference counts for you.</p> </li> <li><p>Modularity and reusability</p> <p>The Perl library is now defined in terms of modules which can be easily shared among various packages. A package may choose to import all or a portion of a module&#39;s published interface. Pragmas (that is, compiler directives) are defined and used by the same mechanism.</p> </li> <li><p>Object-oriented programming</p> <p>A package can function as a class. Dynamic multiple inheritance and virtual methods are supported in a straightforward manner and with very little new syntax. Filehandles may now be treated as objects.</p> </li> <li><p>Embeddable and Extensible</p> <p>Perl may now be embedded easily in your C or C++ application, and can either call or be called by your routines through a documented interface. The XS preprocessor is provided to make it easy to glue your C or C++ routines into Perl. Dynamic loading of modules is supported, and Perl itself can be made into a dynamic library.</p> </li> <li><p>POSIX compliant</p> <p>A major new module is the POSIX module, which provides access to all available POSIX routines and definitions, via object classes where appropriate.</p> </li> <li><p>Package constructors and destructors</p> <p>The new BEGIN and END blocks provide means to capture control as a package is being compiled, and after the program exits. As a degenerate case they work just like awk&#39;s BEGIN and END when you use the <b>-p</b> or <b>-n</b> switches.</p> </li> <li><p>Multiple simultaneous DBM implementations</p> <p>A Perl program may now access DBM, NDBM, SDBM, GDBM, and Berkeley DB files from the same script simultaneously. In fact, the old dbmopen interface has been generalized to allow any variable to be tied to an object class which defines its access methods.</p> </li> <li><p>Subroutine definitions may now be autoloaded</p> <p>In fact, the AUTOLOAD mechanism also allows you to define any arbitrary semantics for undefined subroutine calls. It&#39;s not for just autoloading.</p> </li> <li><p>Regular expression enhancements</p> <p>You can now specify nongreedy quantifiers. You can now do grouping without creating a backreference. You can now write regular expressions with embedded whitespace and comments for readability. A consistent extensibility mechanism has been added that is upwardly compatible with all old regular expressions.</p> </li> <li><p>Innumerable Unbundled Modules</p> <p>The Comprehensive Perl Archive Network described in <a href="/5.005/perlmodlib">perlmodlib</a> contains hundreds of plug-and-play modules full of reusable code. See <i>http://www.perl.com/CPAN</i> for a site near you.</p> </li> <li><p>Compilability</p> <p>While not yet in full production mode, a working perl-to-C compiler does exist. It can generate portable byte code, simple C, or optimized C code.</p> </li> </ul> <p>Okay, that&#39;s <i>definitely</i> enough hype.</p> </div> <div id="footer"> <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p> <p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> <script src="/highlight.pack.js"></script> <script>hljs.highlightAll();</script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10