CINXE.COM
perlvar - Perl predefined variables - 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>perlvar - Perl predefined variables - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/perlvar"> <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.18.0</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/perlvar">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.0/perlvar">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.2/perlvar">5.38.2</a> <a class="dropdown-item" href="/5.38.1/perlvar">5.38.1</a> <a class="dropdown-item" href="/5.38.0/perlvar">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/perlvar">5.36.3</a> <a class="dropdown-item" href="/5.36.2/perlvar">5.36.2</a> <a class="dropdown-item" href="/5.36.1/perlvar">5.36.1</a> <a class="dropdown-item" href="/5.36.0/perlvar">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/perlvar">5.34.3</a> <a class="dropdown-item" href="/5.34.2/perlvar">5.34.2</a> <a class="dropdown-item" href="/5.34.1/perlvar">5.34.1</a> <a class="dropdown-item" href="/5.34.0/perlvar">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/perlvar">5.32.1</a> <a class="dropdown-item" href="/5.32.0/perlvar">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/perlvar">5.30.3</a> <a class="dropdown-item" href="/5.30.2/perlvar">5.30.2</a> <a class="dropdown-item" href="/5.30.1/perlvar">5.30.1</a> <a class="dropdown-item" href="/5.30.0/perlvar">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/perlvar">5.28.3</a> <a class="dropdown-item" href="/5.28.2/perlvar">5.28.2</a> <a class="dropdown-item" href="/5.28.1/perlvar">5.28.1</a> <a class="dropdown-item" href="/5.28.0/perlvar">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/perlvar">5.26.3</a> <a class="dropdown-item" href="/5.26.2/perlvar">5.26.2</a> <a class="dropdown-item" href="/5.26.1/perlvar">5.26.1</a> <a class="dropdown-item" href="/5.26.0/perlvar">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/perlvar">5.24.4</a> <a class="dropdown-item" href="/5.24.3/perlvar">5.24.3</a> <a class="dropdown-item" href="/5.24.2/perlvar">5.24.2</a> <a class="dropdown-item" href="/5.24.1/perlvar">5.24.1</a> <a class="dropdown-item" href="/5.24.0/perlvar">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/perlvar">5.22.4</a> <a class="dropdown-item" href="/5.22.3/perlvar">5.22.3</a> <a class="dropdown-item" href="/5.22.2/perlvar">5.22.2</a> <a class="dropdown-item" href="/5.22.1/perlvar">5.22.1</a> <a class="dropdown-item" href="/5.22.0/perlvar">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/perlvar">5.20.3</a> <a class="dropdown-item" href="/5.20.2/perlvar">5.20.2</a> <a class="dropdown-item" href="/5.20.1/perlvar">5.20.1</a> <a class="dropdown-item" href="/5.20.0/perlvar">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/perlvar">5.18.4</a> <a class="dropdown-item" href="/5.18.3/perlvar">5.18.3</a> <a class="dropdown-item" href="/5.18.2/perlvar">5.18.2</a> <a class="dropdown-item" href="/5.18.1/perlvar">5.18.1</a> <a class="dropdown-item active" href="/5.18.0/perlvar">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/perlvar">5.16.3</a> <a class="dropdown-item" href="/5.16.2/perlvar">5.16.2</a> <a class="dropdown-item" href="/5.16.1/perlvar">5.16.1</a> <a class="dropdown-item" href="/5.16.0/perlvar">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/perlvar">5.14.4</a> <a class="dropdown-item" href="/5.14.3/perlvar">5.14.3</a> <a class="dropdown-item" href="/5.14.2/perlvar">5.14.2</a> <a class="dropdown-item" href="/5.14.1/perlvar">5.14.1</a> <a class="dropdown-item" href="/5.14.0/perlvar">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/perlvar">5.12.5</a> <a class="dropdown-item" href="/5.12.4/perlvar">5.12.4</a> <a class="dropdown-item" href="/5.12.3/perlvar">5.12.3</a> <a class="dropdown-item" href="/5.12.2/perlvar">5.12.2</a> <a class="dropdown-item" href="/5.12.1/perlvar">5.12.1</a> <a class="dropdown-item" href="/5.12.0/perlvar">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/perlvar">5.10.1</a> <a class="dropdown-item" href="/5.10.0/perlvar">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/perlvar">5.8.9</a> <a class="dropdown-item" href="/5.8.8/perlvar">5.8.8</a> <a class="dropdown-item" href="/5.8.7/perlvar">5.8.7</a> <a class="dropdown-item" href="/5.8.6/perlvar">5.8.6</a> <a class="dropdown-item" href="/5.8.5/perlvar">5.8.5</a> <a class="dropdown-item" href="/5.8.4/perlvar">5.8.4</a> <a class="dropdown-item" href="/5.8.3/perlvar">5.8.3</a> <a class="dropdown-item" href="/5.8.2/perlvar">5.8.2</a> <a class="dropdown-item" href="/5.8.1/perlvar">5.8.1</a> <a class="dropdown-item" href="/5.8.0/perlvar">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/perlvar">5.6.2</a> <a class="dropdown-item" href="/5.6.1/perlvar">5.6.1</a> <a class="dropdown-item" href="/5.6.0/perlvar">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/perlvar">5.005_04</a> <a class="dropdown-item" href="/5.005_03/perlvar">5.005_03</a> <a class="dropdown-item" href="/5.005_02/perlvar">5.005_02</a> <a class="dropdown-item" href="/5.005_01/perlvar">5.005_01</a> <a class="dropdown-item" href="/5.005/perlvar">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/perlvar">blead</a> <a class="dropdown-item" href="/5.41.6/perlvar">5.41.6</a> <a class="dropdown-item" href="/5.41.5/perlvar">5.41.5</a> <a class="dropdown-item" href="/5.41.4/perlvar">5.41.4</a> <a class="dropdown-item" href="/5.41.3/perlvar">5.41.3</a> <a class="dropdown-item" href="/5.41.2/perlvar">5.41.2</a> <a class="dropdown-item" href="/5.41.1/perlvar">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.0-RC2/perlvar">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/perlvar">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/perlvar">5.39.10</a> <a class="dropdown-item" href="/5.39.9/perlvar">5.39.9</a> <a class="dropdown-item" href="/5.39.8/perlvar">5.39.8</a> <a class="dropdown-item" href="/5.39.7/perlvar">5.39.7</a> <a class="dropdown-item" href="/5.39.6/perlvar">5.39.6</a> <a class="dropdown-item" href="/5.39.5/perlvar">5.39.5</a> <a class="dropdown-item" href="/5.39.4/perlvar">5.39.4</a> <a class="dropdown-item" href="/5.39.3/perlvar">5.39.3</a> <a class="dropdown-item" href="/5.39.2/perlvar">5.39.2</a> <a class="dropdown-item" href="/5.39.1/perlvar">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.18.0/perl">Perl</a> <a class="dropdown-item" href="/5.18.0/perlintro">Intro</a> <a class="dropdown-item" href="/5.18.0/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.18.0/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.18.0/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.0/perlop">Operators</a> <a class="dropdown-item" href="/5.18.0/functions">Functions</a> <a class="dropdown-item" href="/5.18.0/variables">Variables</a> <a class="dropdown-item" href="/5.18.0/modules">Modules</a> <a class="dropdown-item" href="/5.18.0/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.0/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.18.0/perlcommunity">Community</a> <a class="dropdown-item" href="/5.18.0/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.18.0/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 id="links"> <a href="/5.18.0/perlvar">perlvar</a> <div id="more"> (<a href="/5.18.0/perlvar.txt">source</a>, <a href="https://metacpan.org/pod/perlvar">CPAN</a>) </div> </div> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.18.0. <a href="/perlvar">View the latest version</a> </div> <h1><a id="toc">CONTENTS</a></h1> <ul> <li> <a class="text-decoration-none" href="#NAME">NAME</a> </li> <li> <a class="text-decoration-none" href="#DESCRIPTION">DESCRIPTION</a> <ul> <li> <a class="text-decoration-none" href="#The-Syntax-of-Variable-Names">The Syntax of Variable Names</a> </li> </ul> </li> <li> <a class="text-decoration-none" href="#SPECIAL-VARIABLES">SPECIAL VARIABLES</a> <ul> <li> <a class="text-decoration-none" href="#General-Variables">General Variables</a> </li> <li> <a class="text-decoration-none" href="#Variables-related-to-regular-expressions">Variables related to regular expressions</a> </li> <li> <a class="text-decoration-none" href="#Variables-related-to-filehandles">Variables related to filehandles</a> <ul> <li> <a class="text-decoration-none" href="#Variables-related-to-formats">Variables related to formats</a> </li> </ul> </li> <li> <a class="text-decoration-none" href="#Error-Variables">Error Variables </a> </li> <li> <a class="text-decoration-none" href="#Variables-related-to-the-interpreter-state">Variables related to the interpreter state</a> </li> <li> <a class="text-decoration-none" href="#Deprecated-and-removed-variables">Deprecated and removed variables</a> </li> </ul> </li> </ul> <h1 id="NAME"><a class="permalink" href="#NAME">#</a>NAME</h1> <p>perlvar - Perl predefined variables</p> <h1 id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">#</a>DESCRIPTION</h1> <h2 id="The-Syntax-of-Variable-Names"><a class="permalink" href="#The-Syntax-of-Variable-Names">#</a><a id="The"></a>The Syntax of Variable Names</h2> <p>Variable names in Perl can have several formats. Usually, they must begin with a letter or underscore, in which case they can be arbitrarily long (up to an internal limit of 251 characters) and may contain letters, digits, underscores, or the special sequence <code>::</code> or <code>'</code>. In this case, the part before the last <code>::</code> or <code>'</code> is taken to be a <i>package qualifier</i>; see <a href="/5.18.0/perlmod">perlmod</a>.</p> <p>Perl variable names may also be a sequence of digits or a single punctuation or control character. These names are all reserved for special uses by Perl; for example, the all-digits names are used to hold data captured by backreferences after a regular expression match. Perl has a special syntax for the single-control-character names: It understands <code>^X</code> (caret <code>X</code>) to mean the control-<code>X</code> character. For example, the notation <code>$^W</code> (dollar-sign caret <code>W</code>) is the scalar variable whose name is the single character control-<code>W</code>. This is better than typing a literal control-<code>W</code> into your program.</p> <p>Since Perl v5.6.0, Perl variable names may be alphanumeric strings that begin with control characters (or better yet, a caret). These variables must be written in the form <code>${^Foo}</code>; the braces are not optional. <code>${^Foo}</code> denotes the scalar variable whose name is a control-<code>F</code> followed by two <code>o</code>'s. These variables are reserved for future special uses by Perl, except for the ones that begin with <code>^_</code> (control-underscore or caret-underscore). No control-character name that begins with <code>^_</code> will acquire a special meaning in any future version of Perl; such names may therefore be used safely in programs. <code>$^_</code> itself, however, <i>is</i> reserved.</p> <p>Perl identifiers that begin with digits, control characters, or punctuation characters are exempt from the effects of the <code>package</code> declaration and are always forced to be in package <code>main</code>; they are also exempt from <code>strict 'vars'</code> errors. A few other names are also exempt in these ways:</p> <pre><code class="plaintext">ENV STDIN INC STDOUT ARGV STDERR ARGVOUT SIG</code></pre> <p>In particular, the special <code>${^_XYZ}</code> variables are always taken to be in package <code>main</code>, regardless of any <code>package</code> declarations presently in scope.</p> <h1 id="SPECIAL-VARIABLES"><a class="permalink" href="#SPECIAL-VARIABLES">#</a><a id="SPECIAL"></a>SPECIAL VARIABLES</h1> <p>The following names have special meaning to Perl. Most punctuation names have reasonable mnemonics, or analogs in the shells. Nevertheless, if you wish to use long variable names, you need only say:</p> <pre><code>use English;</code></pre> <p>at the top of your program. This aliases all the short names to the long names in the current package. Some even have medium names, generally borrowed from <b>awk</b>. To avoid a performance hit, if you don't need the <code>$PREMATCH</code>, <code>$MATCH</code>, or <code>$POSTMATCH</code> it's best to use the <code>English</code> module without them:</p> <pre><code>use English '-no_match_vars';</code></pre> <p>Before you continue, note the sort order for variables. In general, we first list the variables in case-insensitive, almost-lexigraphical order (ignoring the <code>{</code> or <code>^</code> preceding words, as in <code>${^UNICODE}</code> or <code>$^T</code>), although <code>$_</code> and <code>@_</code> move up to the top of the pile. For variables with the same identifier, we list it in order of scalar, array, hash, and bareword.</p> <h2 id="General-Variables"><a class="permalink" href="#General-Variables">#</a><a id="General"></a>General Variables</h2> <dl> <dt id="$ARG"><a class="permalink" href="#$ARG">#</a><a id="ARG"></a>$ARG</dt> <dd> </dd> <dt id="$_"><a class="permalink" href="#$_">#</a><a id="pod-_"></a>$_ </dt> <dd> <p>The default input and pattern-searching space. The following pairs are equivalent:</p> <pre><code>while (<>) {...} # equivalent only in while! while (defined($_ = <>)) {...} /^Subject:/ $_ =~ /^Subject:/ tr/a-z/A-Z/ $_ =~ tr/a-z/A-Z/ chomp chomp($_)</code></pre> <p>Here are the places where Perl will assume <code>$_</code> even if you don't use it:</p> <ul> <li><p>The following functions use <code>$_</code> as a default argument:</p> <p>abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, evalbytes, exp, fc, glob, hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print, printf, quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only), rmdir, say, sin, split (for its second argument), sqrt, stat, study, uc, ucfirst, unlink, unpack.</p> </li> <li><p>All file tests (<code>-f</code>, <code>-d</code>) except for <code>-t</code>, which defaults to STDIN. See <a href="/5.18.0/perlfunc#-X">"-X" in perlfunc</a></p> </li> <li><p>The pattern matching operations <code>m//</code>, <code>s///</code> and <code>tr///</code> (aka <code>y///</code>) when used without an <code>=~</code> operator.</p> </li> <li><p>The default iterator variable in a <code>foreach</code> loop if no other variable is supplied.</p> </li> <li><p>The implicit iterator variable in the <code>grep()</code> and <code>map()</code> functions.</p> </li> <li><p>The implicit variable of <code>given()</code>.</p> </li> <li><p>The default place to put the next value or input record when a <code><FH></code>, <code>readline</code>, <code>readdir</code> or <code>each</code> operation's result is tested by itself as the sole criterion of a <code>while</code> test. Outside a <code>while</code> test, this will not happen.</p> </li> </ul> <p><code>$_</code> is by default a global variable. However, as of perl v5.10.0, you can use a lexical version of <code>$_</code> by declaring it in a file or in a block with <code>my</code>. Moreover, declaring <code>our $_</code> restores the global <code>$_</code> in the current scope. Though this seemed like a good idea at the time it was introduced, lexical <code>$_</code> actually causes more problems than it solves. If you call a function that expects to be passed information via <code>$_</code>, it may or may not work, depending on how the function is written, there not being any easy way to solve this. Just avoid lexical <code>$_</code>, unless you are feeling particularly masochistic. For this reason lexical <code>$_</code> is still experimental and will produce a warning unless warnings have been disabled. As with other experimental features, the behavior of lexical <code>$_</code> is subject to change without notice, including change into a fatal error.</p> <p>Mnemonic: underline is understood in certain operations.</p> </dd> <dt id="@ARG"><a class="permalink" href="#@ARG">#</a><a id="ARG1"></a>@ARG</dt> <dd> </dd> <dt id="@_"><a class="permalink" href="#@_">#</a><a id="pod-_1"></a>@_ </dt> <dd> <p>Within a subroutine the array <code>@_</code> contains the parameters passed to that subroutine. Inside a subroutine, <code>@_</code> is the default array for the array operators <code>push</code>, <code>pop</code>, <code>shift</code>, and <code>unshift</code>.</p> <p>See <a href="/5.18.0/perlsub">perlsub</a>.</p> </dd> <dt id="$LIST_SEPARATOR"><a class="permalink" href="#$LIST_SEPARATOR">#</a><a id="LIST_SEPARATOR"></a>$LIST_SEPARATOR</dt> <dd> </dd> <dt id="$""><a class="permalink" href="#$%22">#</a><a id="pod"></a>$" </dt> <dd> <p>When an array or an array slice is interpolated into a double-quoted string or a similar context such as <code>/.../</code>, its elements are separated by this value. Default is a space. For example, this:</p> <pre><code>print "The array is: @array\n";</code></pre> <p>is equivalent to this:</p> <pre><code>print "The array is: " . join($", @array) . "\n";</code></pre> <p>Mnemonic: works in double-quoted context.</p> </dd> <dt id="$PROCESS_ID"><a class="permalink" href="#$PROCESS_ID">#</a><a id="PROCESS_ID"></a>$PROCESS_ID</dt> <dd> </dd> <dt id="$PID"><a class="permalink" href="#$PID">#</a><a id="PID"></a>$PID</dt> <dd> </dd> <dt id="$$"><a class="permalink" href="#$$">#</a><a id="pod1"></a>$$ </dt> <dd> <p>The process number of the Perl running this script. Though you <i>can</i> set this variable, doing so is generally discouraged, although it can be invaluable for some testing purposes. It will be reset automatically across <code>fork()</code> calls.</p> <p>Note for Linux and Debian GNU/kFreeBSD users: Before Perl v5.16.0 perl would emulate POSIX semantics on Linux systems using LinuxThreads, a partial implementation of POSIX Threads that has since been superseded by the Native POSIX Thread Library (NPTL).</p> <p>LinuxThreads is now obsolete on Linux, and caching <code>getpid()</code> like this made embedding perl unnecessarily complex (since you'd have to manually update the value of $$), so now <code>$$</code> and <code>getppid()</code> will always return the same values as the underlying C library.</p> <p>Debian GNU/kFreeBSD systems also used LinuxThreads up until and including the 6.0 release, but after that moved to FreeBSD thread semantics, which are POSIX-like.</p> <p>To see if your system is affected by this discrepancy check if <code>getconf GNU_LIBPTHREAD_VERSION | grep -q NPTL</code> returns a false value. NTPL threads preserve the POSIX semantics.</p> <p>Mnemonic: same as shells.</p> </dd> <dt id="$PROGRAM_NAME"><a class="permalink" href="#$PROGRAM_NAME">#</a><a id="PROGRAM_NAME"></a>$PROGRAM_NAME</dt> <dd> </dd> <dt id="$0"><a class="permalink" href="#$0">#</a><a id="pod-0"></a>$0 </dt> <dd> <p>Contains the name of the program being executed.</p> <p>On some (but not all) operating systems assigning to <code>$0</code> modifies the argument area that the <code>ps</code> program sees. On some platforms you may have to use special <code>ps</code> options or a different <code>ps</code> to see the changes. Modifying the <code>$0</code> is more useful as a way of indicating the current program state than it is for hiding the program you're running.</p> <p>Note that there are platform-specific limitations on the maximum length of <code>$0</code>. In the most extreme case it may be limited to the space occupied by the original <code>$0</code>.</p> <p>In some platforms there may be arbitrary amount of padding, for example space characters, after the modified name as shown by <code>ps</code>. In some platforms this padding may extend all the way to the original length of the argument area, no matter what you do (this is the case for example with Linux 2.2).</p> <p>Note for BSD users: setting <code>$0</code> does not completely remove "perl" from the ps(1) output. For example, setting <code>$0</code> to <code>"foobar"</code> may result in <code>"perl: foobar (perl)"</code> (whether both the <code>"perl: "</code> prefix and the " (perl)" suffix are shown depends on your exact BSD variant and version). This is an operating system feature, Perl cannot help it.</p> <p>In multithreaded scripts Perl coordinates the threads so that any thread may modify its copy of the <code>$0</code> and the change becomes visible to ps(1) (assuming the operating system plays along). Note that the view of <code>$0</code> the other threads have will not change since they have their own copies of it.</p> <p>If the program has been given to perl via the switches <code>-e</code> or <code>-E</code>, <code>$0</code> will contain the string <code>"-e"</code>.</p> <p>On Linux as of perl v5.14.0 the legacy process name will be set with <code>prctl(2)</code>, in addition to altering the POSIX name via <code>argv[0]</code> as perl has done since version 4.000. Now system utilities that read the legacy process name such as ps, top and killall will recognize the name you set when assigning to <code>$0</code>. The string you supply will be cut off at 16 bytes, this is a limitation imposed by Linux.</p> <p>Mnemonic: same as <b>sh</b> and <b>ksh</b>.</p> </dd> <dt id="$REAL_GROUP_ID"><a class="permalink" href="#$REAL_GROUP_ID">#</a><a id="REAL_GROUP_ID"></a>$REAL_GROUP_ID</dt> <dd> </dd> <dt id="$GID"><a class="permalink" href="#$GID">#</a><a id="GID"></a>$GID</dt> <dd> </dd> <dt id="$("><a class="permalink" href="#$(">#</a><a id="pod2"></a>$( </dt> <dd> <p>The real gid of this process. If you are on a machine that supports membership in multiple groups simultaneously, gives a space separated list of groups you are in. The first number is the one returned by <code>getgid()</code>, and the subsequent ones by <code>getgroups()</code>, one of which may be the same as the first number.</p> <p>However, a value assigned to <code>$(</code> must be a single number used to set the real gid. So the value given by <code>$(</code> should <i>not</i> be assigned back to <code>$(</code> without being forced numeric, such as by adding zero. Note that this is different to the effective gid (<code>$)</code>) which does take a list.</p> <p>You can change both the real gid and the effective gid at the same time by using <code>POSIX::setgid()</code>. Changes to <code>$(</code> require a check to <code>$!</code> to detect any possible errors after an attempted change.</p> <p>Mnemonic: parentheses are used to <i>group</i> things. The real gid is the group you <i>left</i>, if you're running setgid.</p> </dd> <dt id="$EFFECTIVE_GROUP_ID"><a class="permalink" href="#$EFFECTIVE_GROUP_ID">#</a><a id="EFFECTIVE_GROUP_ID"></a>$EFFECTIVE_GROUP_ID</dt> <dd> </dd> <dt id="$EGID"><a class="permalink" href="#$EGID">#</a><a id="EGID"></a>$EGID</dt> <dd> </dd> <dt id="$)"><a class="permalink" href="#$)">#</a><a id="pod3"></a>$) </dt> <dd> <p>The effective gid of this process. If you are on a machine that supports membership in multiple groups simultaneously, gives a space separated list of groups you are in. The first number is the one returned by <code>getegid()</code>, and the subsequent ones by <code>getgroups()</code>, one of which may be the same as the first number.</p> <p>Similarly, a value assigned to <code>$)</code> must also be a space-separated list of numbers. The first number sets the effective gid, and the rest (if any) are passed to <code>setgroups()</code>. To get the effect of an empty list for <code>setgroups()</code>, just repeat the new effective gid; that is, to force an effective gid of 5 and an effectively empty <code>setgroups()</code> list, say <code> $) = "5 5" </code>.</p> <p>You can change both the effective gid and the real gid at the same time by using <code>POSIX::setgid()</code> (use only a single numeric argument). Changes to <code>$)</code> require a check to <code>$!</code> to detect any possible errors after an attempted change.</p> <p><code>$<</code>, <code>$></code>, <code>$(</code> and <code>$)</code> can be set only on machines that support the corresponding <i>set[re][ug]id()</i> routine. <code>$(</code> and <code>$)</code> can be swapped only on machines supporting <code>setregid()</code>.</p> <p>Mnemonic: parentheses are used to <i>group</i> things. The effective gid is the group that's <i>right</i> for you, if you're running setgid.</p> </dd> <dt id="$REAL_USER_ID"><a class="permalink" href="#$REAL_USER_ID">#</a><a id="REAL_USER_ID"></a>$REAL_USER_ID</dt> <dd> </dd> <dt id="$UID"><a class="permalink" href="#$UID">#</a><a id="UID"></a>$UID</dt> <dd> </dd> <dt id="$<"><a class="permalink" href="#$%3C">#</a><a id="pod4"></a>$< </dt> <dd> <p>The real uid of this process. You can change both the real uid and the effective uid at the same time by using <code>POSIX::setuid()</code>. Since changes to <code>$<</code> require a system call, check <code>$!</code> after a change attempt to detect any possible errors.</p> <p>Mnemonic: it's the uid you came <i>from</i>, if you're running setuid.</p> </dd> <dt id="$EFFECTIVE_USER_ID"><a class="permalink" href="#$EFFECTIVE_USER_ID">#</a><a id="EFFECTIVE_USER_ID"></a>$EFFECTIVE_USER_ID</dt> <dd> </dd> <dt id="$EUID"><a class="permalink" href="#$EUID">#</a><a id="EUID"></a>$EUID</dt> <dd> </dd> <dt id="$>"><a class="permalink" href="#$%3E">#</a><a id="pod5"></a>$> </dt> <dd> <p>The effective uid of this process. For example:</p> <pre><code>$< = $>; # set real to effective uid ($<,$>) = ($>,$<); # swap real and effective uids</code></pre> <p>You can change both the effective uid and the real uid at the same time by using <code>POSIX::setuid()</code>. Changes to <code>$></code> require a check to <code>$!</code> to detect any possible errors after an attempted change.</p> <p><code>$<</code> and <code>$></code> can be swapped only on machines supporting <code>setreuid()</code>.</p> <p>Mnemonic: it's the uid you went <i>to</i>, if you're running setuid.</p> </dd> <dt id="$SUBSCRIPT_SEPARATOR"><a class="permalink" href="#$SUBSCRIPT_SEPARATOR">#</a><a id="SUBSCRIPT_SEPARATOR"></a>$SUBSCRIPT_SEPARATOR</dt> <dd> </dd> <dt id="$SUBSEP"><a class="permalink" href="#$SUBSEP">#</a><a id="SUBSEP"></a>$SUBSEP</dt> <dd> </dd> <dt id="$;"><a class="permalink" href="#$;">#</a><a id="pod6"></a>$; </dt> <dd> <p>The subscript separator for multidimensional array emulation. If you refer to a hash element as</p> <pre><code>$foo{$a,$b,$c}</code></pre> <p>it really means</p> <pre><code>$foo{join($;, $a, $b, $c)}</code></pre> <p>But don't put</p> <pre><code>@foo{$a,$b,$c} # a slice--note the @</code></pre> <p>which means</p> <pre><code>($foo{$a},$foo{$b},$foo{$c})</code></pre> <p>Default is "\034", the same as SUBSEP in <b>awk</b>. If your keys contain binary data there might not be any safe value for <code>$;</code>.</p> <p>Consider using "real" multidimensional arrays as described in <a href="/5.18.0/perllol">perllol</a>.</p> <p>Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon.</p> </dd> <dt id="$a"><a class="permalink" href="#$a">#</a><a id="a"></a>$a</dt> <dd> </dd> <dt id="$b"><a class="permalink" href="#$b">#</a><a id="b"></a>$b </dt> <dd> <p>Special package variables when using <code>sort()</code>, see <a href="/5.18.0/perlfunc#sort">"sort" in perlfunc</a>. Because of this specialness <code>$a</code> and <code>$b</code> don't need to be declared (using <code>use vars</code>, or <code>our()</code>) even when using the <code>strict 'vars'</code> pragma. Don't lexicalize them with <code>my $a</code> or <code>my $b</code> if you want to be able to use them in the <code>sort()</code> comparison block or function.</p> </dd> <dt id="%ENV"><a class="permalink" href="#%25ENV">#</a><a id="ENV"></a>%ENV </dt> <dd> <p>The hash <code>%ENV</code> contains your current environment. Setting a value in <code>ENV</code> changes the environment for any child processes you subsequently <code>fork()</code> off.</p> </dd> <dt id="$SYSTEM_FD_MAX"><a class="permalink" href="#$SYSTEM_FD_MAX">#</a><a id="SYSTEM_FD_MAX"></a>$SYSTEM_FD_MAX</dt> <dd> </dd> <dt id="$^F"><a class="permalink" href="#$%5EF">#</a><a id="F"></a>$^F </dt> <dd> <p>The maximum system file descriptor, ordinarily 2. System file descriptors are passed to <code>exec()</code>ed processes, while higher file descriptors are not. Also, during an <code>open()</code>, system file descriptors are preserved even if the <code>open()</code> fails (ordinary file descriptors are closed before the <code>open()</code> is attempted). The close-on-exec status of a file descriptor will be decided according to the value of <code>$^F</code> when the corresponding file, pipe, or socket was opened, not the time of the <code>exec()</code>.</p> </dd> <dt id="@F"><a class="permalink" href="#@F">#</a><a id="F1"></a>@F </dt> <dd> <p>The array <code>@F</code> contains the fields of each line read in when autosplit mode is turned on. See <a href="/5.18.0/perlrun">perlrun</a> for the <b>-a</b> switch. This array is package-specific, and must be declared or given a full package name if not in package main when running under <code>strict 'vars'</code>.</p> </dd> <dt id="@INC"><a class="permalink" href="#@INC">#</a><a id="INC"></a>@INC </dt> <dd> <p>The array <code>@INC</code> contains the list of places that the <code>do EXPR</code>, <code>require</code>, or <code>use</code> constructs look for their library files. It initially consists of the arguments to any <b>-I</b> command-line switches, followed by the default Perl library, probably <i>/usr/local/lib/perl</i>, followed by ".", to represent the current directory. ("." will not be appended if taint checks are enabled, either by <code>-T</code> or by <code>-t</code>.) If you need to modify this at runtime, you should use the <code>use lib</code> pragma to get the machine-dependent library properly loaded also:</p> <pre><code>use lib '/mypath/libdir/'; use SomeMod;</code></pre> <p>You can also insert hooks into the file inclusion system by putting Perl code directly into <code>@INC</code>. Those hooks may be subroutine references, array references or blessed objects. See <a href="/5.18.0/perlfunc#require">"require" in perlfunc</a> for details.</p> </dd> <dt id="%INC"><a class="permalink" href="#%25INC">#</a><a id="INC1"></a>%INC </dt> <dd> <p>The hash <code>%INC</code> contains entries for each filename included via the <code>do</code>, <code>require</code>, or <code>use</code> operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. The <code>require</code> operator uses this hash to determine whether a particular file has already been included.</p> <p>If the file was loaded via a hook (e.g. a subroutine reference, see <a href="/5.18.0/perlfunc#require">"require" in perlfunc</a> for a description of these hooks), this hook is by default inserted into <code>%INC</code> in place of a filename. Note, however, that the hook may have set the <code>%INC</code> entry by itself to provide some more specific info.</p> </dd> <dt id="$INPLACE_EDIT"><a class="permalink" href="#$INPLACE_EDIT">#</a><a id="INPLACE_EDIT"></a>$INPLACE_EDIT</dt> <dd> </dd> <dt id="$^I"><a class="permalink" href="#$%5EI">#</a><a id="I"></a>$^I </dt> <dd> <p>The current value of the inplace-edit extension. Use <code>undef</code> to disable inplace editing.</p> <p>Mnemonic: value of <b>-i</b> switch.</p> </dd> <dt id="$^M"><a class="permalink" href="#$%5EM">#</a><a id="M"></a>$^M </dt> <dd> <p>By default, running out of memory is an untrappable, fatal error. However, if suitably built, Perl can use the contents of <code>$^M</code> as an emergency memory pool after <code>die()</code>ing. Suppose that your Perl were compiled with <code>-DPERL_EMERGENCY_SBRK</code> and used Perl's malloc. Then</p> <pre><code>$^M = 'a' x (1 << 16);</code></pre> <p>would allocate a 64K buffer for use in an emergency. See the <i>INSTALL</i> file in the Perl distribution for information on how to add custom C compilation flags when compiling perl. To discourage casual use of this advanced feature, there is no <a href="/5.18.0/English">English</a> long name for this variable.</p> <p>This variable was added in Perl 5.004.</p> </dd> <dt id="$OSNAME"><a class="permalink" href="#$OSNAME">#</a><a id="OSNAME"></a>$OSNAME</dt> <dd> </dd> <dt id="$^O"><a class="permalink" href="#$%5EO">#</a><a id="O"></a>$^O </dt> <dd> <p>The name of the operating system under which this copy of Perl was built, as determined during the configuration process. For examples see <a href="/5.18.0/perlport#PLATFORMS">"PLATFORMS" in perlport</a>.</p> <p>The value is identical to <code>$Config{'osname'}</code>. See also <a href="/5.18.0/Config">Config</a> and the <b>-V</b> command-line switch documented in <a href="/5.18.0/perlrun">perlrun</a>.</p> <p>In Windows platforms, <code>$^O</code> is not very helpful: since it is always <code>MSWin32</code>, it doesn't tell the difference between 95/98/ME/NT/2000/XP/CE/.NET. Use <code>Win32::GetOSName()</code> or Win32::GetOSVersion() (see <a href="/5.18.0/Win32">Win32</a> and <a href="/5.18.0/perlport">perlport</a>) to distinguish between the variants.</p> <p>This variable was added in Perl 5.003.</p> </dd> <dt id="%SIG"><a class="permalink" href="#%25SIG">#</a><a id="SIG"></a>%SIG </dt> <dd> <p>The hash <code>%SIG</code> contains signal handlers for signals. For example:</p> <pre><code> sub handler { # 1st argument is signal name my($sig) = @_; print "Caught a SIG$sig--shutting down\n"; close(LOG); exit(0); } $SIG{'INT'} = \&handler; $SIG{'QUIT'} = \&handler; ... $SIG{'INT'} = 'DEFAULT'; # restore default action $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT</code></pre> <p>Using a value of <code>'IGNORE'</code> usually has the effect of ignoring the signal, except for the <code>CHLD</code> signal. See <a href="/5.18.0/perlipc">perlipc</a> for more about this special case.</p> <p>Here are some other examples:</p> <pre><code> $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not # recommended) $SIG{"PIPE"} = \&Plumber; # just fine; assume current # Plumber $SIG{"PIPE"} = *Plumber; # somewhat esoteric $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() # return??</code></pre> <p>Be sure not to use a bareword as the name of a signal handler, lest you inadvertently call it.</p> <p>If your system has the <code>sigaction()</code> function then signal handlers are installed using it. This means you get reliable signal handling.</p> <p>The default delivery policy of signals changed in Perl v5.8.0 from immediate (also known as "unsafe") to deferred, also known as "safe signals". See <a href="/5.18.0/perlipc">perlipc</a> for more information.</p> <p>Certain internal hooks can be also set using the <code>%SIG</code> hash. The routine indicated by <code>$SIG{__WARN__}</code> is called when a warning message is about to be printed. The warning message is passed as the first argument. The presence of a <code>__WARN__</code> hook causes the ordinary printing of warnings to <code>STDERR</code> to be suppressed. You can use this to save warnings in a variable, or turn warnings into fatal errors, like this:</p> <pre><code>local $SIG{__WARN__} = sub { die $_[0] }; eval $proggie;</code></pre> <p>As the <code>'IGNORE'</code> hook is not supported by <code>__WARN__</code>, you can disable warnings using the empty subroutine:</p> <pre><code>local $SIG{__WARN__} = sub {};</code></pre> <p>The routine indicated by <code>$SIG{__DIE__}</code> is called when a fatal exception is about to be thrown. The error message is passed as the first argument. When a <code>__DIE__</code> hook routine returns, the exception processing continues as it would have in the absence of the hook, unless the hook routine itself exits via a <code>goto &sub</code>, a loop exit, or a <code>die()</code>. The <code>__DIE__</code> handler is explicitly disabled during the call, so that you can die from a <code>__DIE__</code> handler. Similarly for <code>__WARN__</code>.</p> <p>Due to an implementation glitch, the <code>$SIG{__DIE__}</code> hook is called even inside an <code>eval()</code>. Do not use this to rewrite a pending exception in <code>$@</code>, or as a bizarre substitute for overriding <code>CORE::GLOBAL::die()</code>. This strange action at a distance may be fixed in a future release so that <code>$SIG{__DIE__}</code> is only called if your program is about to exit, as was the original intent. Any other use is deprecated.</p> <p><code>__DIE__</code>/<code>__WARN__</code> handlers are very special in one respect: they may be called to report (probable) errors found by the parser. In such a case the parser may be in inconsistent state, so any attempt to evaluate Perl code from such a handler will probably result in a segfault. This means that warnings or errors that result from parsing Perl should be used with extreme caution, like this:</p> <pre><code>require Carp if defined $^S; Carp::confess("Something wrong") if defined &Carp::confess; die "Something wrong, but could not load Carp to give " . "backtrace...\n\t" . "To see backtrace try starting Perl with -MCarp switch";</code></pre> <p>Here the first line will load <code>Carp</code> <i>unless</i> it is the parser who called the handler. The second line will print backtrace and die if <code>Carp</code> was available. The third line will be executed only if <code>Carp</code> was not available.</p> <p>Having to even think about the <code>$^S</code> variable in your exception handlers is simply wrong. <code>$SIG{__DIE__}</code> as currently implemented invites grievous and difficult to track down errors. Avoid it and use an <code>END{}</code> or CORE::GLOBAL::die override instead.</p> <p>See <a href="/5.18.0/perlfunc#die">"die" in perlfunc</a>, <a href="/5.18.0/perlfunc#warn">"warn" in perlfunc</a>, <a href="/5.18.0/perlfunc#eval">"eval" in perlfunc</a>, and <a href="/5.18.0/warnings">warnings</a> for additional information.</p> </dd> <dt id="$BASETIME"><a class="permalink" href="#$BASETIME">#</a><a id="BASETIME"></a>$BASETIME</dt> <dd> </dd> <dt id="$^T"><a class="permalink" href="#$%5ET">#</a><a id="T"></a>$^T </dt> <dd> <p>The time at which the program began running, in seconds since the epoch (beginning of 1970). The values returned by the <b>-M</b>, <b>-A</b>, and <b>-C</b> filetests are based on this value.</p> </dd> <dt id="$PERL_VERSION"><a class="permalink" href="#$PERL_VERSION">#</a><a id="PERL_VERSION"></a>$PERL_VERSION</dt> <dd> </dd> <dt id="$^V"><a class="permalink" href="#$%5EV">#</a><a id="V"></a>$^V </dt> <dd> <p>The revision, version, and subversion of the Perl interpreter, represented as a <code>version</code> object.</p> <p>This variable first appeared in perl v5.6.0; earlier versions of perl will see an undefined value. Before perl v5.10.0 <code>$^V</code> was represented as a v-string.</p> <p><code>$^V</code> can be used to determine whether the Perl interpreter executing a script is in the right range of versions. For example:</p> <pre><code class="plaintext">warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1</code></pre> <p>To convert <code>$^V</code> into its string representation use <code>sprintf()</code>'s <code>"%vd"</code> conversion:</p> <pre><code>printf "version is v%vd\n", $^V; # Perl's version</code></pre> <p>See the documentation of <code>use VERSION</code> and <code>require VERSION</code> for a convenient way to fail if the running Perl interpreter is too old.</p> <p>See also <code>$]</code> for an older representation of the Perl version.</p> <p>This variable was added in Perl v5.6.0.</p> <p>Mnemonic: use ^V for Version Control.</p> </dd> <dt id="${^WIN32_SLOPPY_STAT}"><a class="permalink" href="#$%7B%5EWIN32_SLOPPY_STAT%7D">#</a><a id="WIN32_SLOPPY_STAT"></a>${^WIN32_SLOPPY_STAT} </dt> <dd> <p>If this variable is set to a true value, then <code>stat()</code> on Windows will not try to open the file. This means that the link count cannot be determined and file attributes may be out of date if additional hardlinks to the file exist. On the other hand, not opening the file is considerably faster, especially for files on network drives.</p> <p>This variable could be set in the <i>sitecustomize.pl</i> file to configure the local Perl installation to use "sloppy" <code>stat()</code> by default. See the documentation for <b>-f</b> in <a href="/5.18.0/perlrun#Command-Switches">perlrun</a> for more information about site customization.</p> <p>This variable was added in Perl v5.10.0.</p> </dd> <dt id="$EXECUTABLE_NAME"><a class="permalink" href="#$EXECUTABLE_NAME">#</a><a id="EXECUTABLE_NAME"></a>$EXECUTABLE_NAME</dt> <dd> </dd> <dt id="$^X"><a class="permalink" href="#$%5EX">#</a><a id="X"></a>$^X </dt> <dd> <p>The name used to execute the current copy of Perl, from C's <code>argv[0]</code> or (where supported) <i>/proc/self/exe</i>.</p> <p>Depending on the host operating system, the value of <code>$^X</code> may be a relative or absolute pathname of the perl program file, or may be the string used to invoke perl but not the pathname of the perl program file. Also, most operating systems permit invoking programs that are not in the PATH environment variable, so there is no guarantee that the value of <code>$^X</code> is in PATH. For VMS, the value may or may not include a version number.</p> <p>You usually can use the value of <code>$^X</code> to re-invoke an independent copy of the same perl that is currently running, e.g.,</p> <pre><code>@first_run = `$^X -le "print int rand 100 for 1..100"`;</code></pre> <p>But recall that not all operating systems support forking or capturing of the output of commands, so this complex statement may not be portable.</p> <p>It is not safe to use the value of <code>$^X</code> as a path name of a file, as some operating systems that have a mandatory suffix on executable files do not require use of the suffix when invoking a command. To convert the value of <code>$^X</code> to a path name, use the following statements:</p> <pre><code> # Build up a set of file names (not command names). use Config; my $this_perl = $^X; if ($^O ne 'VMS') { $this_perl .= $Config{_exe} unless $this_perl =~ m/$Config{_exe}$/i; }</code></pre> <p>Because many operating systems permit anyone with read access to the Perl program file to make a copy of it, patch the copy, and then execute the copy, the security-conscious Perl programmer should take care to invoke the installed copy of perl, not the copy referenced by <code>$^X</code>. The following statements accomplish this goal, and produce a pathname that can be invoked as a command or referenced as a file.</p> <pre><code> use Config; my $secure_perl_path = $Config{perlpath}; if ($^O ne 'VMS') { $secure_perl_path .= $Config{_exe} unless $secure_perl_path =~ m/$Config{_exe}$/i; }</code></pre> </dd> </dl> <h2 id="Variables-related-to-regular-expressions"><a class="permalink" href="#Variables-related-to-regular-expressions">#</a><a id="Variables"></a>Variables related to regular expressions</h2> <p>Most of the special variables related to regular expressions are side effects. Perl sets these variables when it has a successful match, so you should check the match result before using them. For instance:</p> <pre><code> if( /P(A)TT(ER)N/ ) { print "I found $1 and $2\n"; }</code></pre> <p>These variables are read-only and dynamically-scoped, unless we note otherwise.</p> <p>The dynamic nature of the regular expression variables means that their value is limited to the block that they are in, as demonstrated by this bit of code:</p> <pre><code> my $outer = 'Wallace and Grommit'; my $inner = 'Mutt and Jeff'; my $pattern = qr/(\S+) and (\S+)/; sub show_n { print "\$1 is $1; \$2 is $2\n" } { OUTER: show_n() if $outer =~ m/$pattern/; INNER: { show_n() if $inner =~ m/$pattern/; } show_n(); }</code></pre> <p>The output shows that while in the <code>OUTER</code> block, the values of <code>$1</code> and <code>$2</code> are from the match against <code>$outer</code>. Inside the <code>INNER</code> block, the values of <code>$1</code> and <code>$2</code> are from the match against <code>$inner</code>, but only until the end of the block (i.e. the dynamic scope). After the <code>INNER</code> block completes, the values of <code>$1</code> and <code>$2</code> return to the values for the match against <code>$outer</code> even though we have not made another match:</p> <pre><code>$1 is Wallace; $2 is Grommit $1 is Mutt; $2 is Jeff $1 is Wallace; $2 is Grommit</code></pre> <p>Due to an unfortunate accident of Perl's implementation, <code>use English</code> imposes a considerable performance penalty on all regular expression matches in a program because it uses the <code>$`</code>, <code>$&</code>, and <code>$'</code>, regardless of whether they occur in the scope of <code>use English</code>. For that reason, saying <code>use English</code> in libraries is strongly discouraged unless you import it without the match variables:</p> <pre><code class="plaintext">use English '-no_match_vars'</code></pre> <p>The <code>Devel::NYTProf</code> and <code>Devel::FindAmpersand</code> modules can help you find uses of these problematic match variables in your code.</p> <p>Since Perl v5.10.0, you can use the <code>/p</code> match operator flag and the <code>${^PREMATCH}</code>, <code>${^MATCH}</code>, and <code>${^POSTMATCH}</code> variables instead so you only suffer the performance penalties.</p> <dl> <dt id="$<digits>-($1,-$2,-...)"><a class="permalink" href="#$%3Cdigits%3E-($1,-$2,-...)">#</a><a id="digits-1-2"></a>$<<i>digits</i>> ($1, $2, ...) </dt> <dd> <p>Contains the subpattern from the corresponding set of capturing parentheses from the last successful pattern match, not counting patterns matched in nested blocks that have been exited already.</p> <p>These variables are read-only and dynamically-scoped.</p> <p>Mnemonic: like \digits.</p> </dd> <dt id="$MATCH"><a class="permalink" href="#$MATCH">#</a><a id="MATCH"></a>$MATCH</dt> <dd> </dd> <dt id="$&"><a class="permalink" href="#$&">#</a><a id="pod7"></a>$& </dt> <dd> <p>The string matched by the last successful pattern match (not counting any matches hidden within a BLOCK or <code>eval()</code> enclosed by the current BLOCK).</p> <p>The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. To avoid this penalty, you can extract the same substring by using <a href="#%40-">"@-"</a>. Starting with Perl v5.10.0, you can use the <code>/p</code> match flag and the <code>${^MATCH}</code> variable to do the same thing for particular match operations.</p> <p>This variable is read-only and dynamically-scoped.</p> <p>Mnemonic: like <code>&</code> in some editors.</p> </dd> <dt id="${^MATCH}"><a class="permalink" href="#$%7B%5EMATCH%7D">#</a><a id="MATCH1"></a>${^MATCH} </dt> <dd> <p>This is similar to <code>$&</code> (<code>$MATCH</code>) except that it does not incur the performance penalty associated with that variable, and is only guaranteed to return a defined value when the pattern was compiled or executed with the <code>/p</code> modifier.</p> <p>This variable was added in Perl v5.10.0.</p> <p>This variable is read-only and dynamically-scoped.</p> </dd> <dt id="$PREMATCH"><a class="permalink" href="#$PREMATCH">#</a><a id="PREMATCH"></a>$PREMATCH</dt> <dd> </dd> <dt id="$`"><a class="permalink" href="#$%60">#</a><a id="pod8"></a>$` </dt> <dd> <p>The string preceding whatever was matched by the last successful pattern match, not counting any matches hidden within a BLOCK or <code>eval</code> enclosed by the current BLOCK.</p> <p>The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. To avoid this penalty, you can extract the same substring by using <a href="#%40-">"@-"</a>. Starting with Perl v5.10.0, you can use the <code>/p</code> match flag and the <code>${^PREMATCH}</code> variable to do the same thing for particular match operations.</p> <p>This variable is read-only and dynamically-scoped.</p> <p>Mnemonic: <code>`</code> often precedes a quoted string.</p> </dd> <dt id="${^PREMATCH}"><a class="permalink" href="#$%7B%5EPREMATCH%7D">#</a><a id="PREMATCH1"></a>${^PREMATCH} </dt> <dd> <p>This is similar to <code>$`</code> ($PREMATCH) except that it does not incur the performance penalty associated with that variable, and is only guaranteed to return a defined value when the pattern was compiled or executed with the <code>/p</code> modifier.</p> <p>This variable was added in Perl v5.10.0</p> <p>This variable is read-only and dynamically-scoped.</p> </dd> <dt id="$POSTMATCH"><a class="permalink" href="#$POSTMATCH">#</a><a id="POSTMATCH"></a>$POSTMATCH</dt> <dd> </dd> <dt id="$'"><a class="permalink" href="#$'">#</a><a id="pod9"></a>$' </dt> <dd> <p>The string following whatever was matched by the last successful pattern match (not counting any matches hidden within a BLOCK or <code>eval()</code> enclosed by the current BLOCK). Example:</p> <pre><code>local $_ = 'abcdefghi'; /def/; print "$`:$&:$'\n"; # prints abc:def:ghi</code></pre> <p>The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. To avoid this penalty, you can extract the same substring by using <a href="#%40-">"@-"</a>. Starting with Perl v5.10.0, you can use the <code>/p</code> match flag and the <code>${^POSTMATCH}</code> variable to do the same thing for particular match operations.</p> <p>This variable is read-only and dynamically-scoped.</p> <p>Mnemonic: <code>'</code> often follows a quoted string.</p> </dd> <dt id="${^POSTMATCH}"><a class="permalink" href="#$%7B%5EPOSTMATCH%7D">#</a><a id="POSTMATCH1"></a>${^POSTMATCH} </dt> <dd> <p>This is similar to <code>$'</code> (<code>$POSTMATCH</code>) except that it does not incur the performance penalty associated with that variable, and is only guaranteed to return a defined value when the pattern was compiled or executed with the <code>/p</code> modifier.</p> <p>This variable was added in Perl v5.10.0.</p> <p>This variable is read-only and dynamically-scoped.</p> </dd> <dt id="$LAST_PAREN_MATCH"><a class="permalink" href="#$LAST_PAREN_MATCH">#</a><a id="LAST_PAREN_MATCH"></a>$LAST_PAREN_MATCH</dt> <dd> </dd> <dt id="$+"><a class="permalink" href="#$+">#</a><a id="pod10"></a>$+ </dt> <dd> <p>The text matched by the last bracket of the last successful search pattern. This is useful if you don't know which one of a set of alternative patterns matched. For example:</p> <pre><code>/Version: (.*)|Revision: (.*)/ && ($rev = $+);</code></pre> <p>This variable is read-only and dynamically-scoped.</p> <p>Mnemonic: be positive and forward looking.</p> </dd> <dt id="$LAST_SUBMATCH_RESULT"><a class="permalink" href="#$LAST_SUBMATCH_RESULT">#</a><a id="LAST_SUBMATCH_RESULT"></a>$LAST_SUBMATCH_RESULT</dt> <dd> </dd> <dt id="$^N"><a class="permalink" href="#$%5EN">#</a><a id="N"></a>$^N </dt> <dd> <p>The text matched by the used group most-recently closed (i.e. the group with the rightmost closing parenthesis) of the last successful search pattern.</p> <p>This is primarily used inside <code>(?{...})</code> blocks for examining text recently matched. For example, to effectively capture text to a variable (in addition to <code>$1</code>, <code>$2</code>, etc.), replace <code>(...)</code> with</p> <pre><code>(?:(...)(?{ $var = $^N }))</code></pre> <p>By setting and then using <code>$var</code> in this way relieves you from having to worry about exactly which numbered set of parentheses they are.</p> <p>This variable was added in Perl v5.8.0.</p> <p>Mnemonic: the (possibly) Nested parenthesis that most recently closed.</p> </dd> <dt id="@LAST_MATCH_END"><a class="permalink" href="#@LAST_MATCH_END">#</a><a id="LAST_MATCH_END"></a>@LAST_MATCH_END</dt> <dd> </dd> <dt id="@+"><a class="permalink" href="#@+">#</a><a id="pod11"></a>@+ </dt> <dd> <p>This array holds the offsets of the ends of the last successful submatches in the currently active dynamic scope. <code>$+[0]</code> is the offset into the string of the end of the entire match. This is the same value as what the <code>pos</code> function returns when called on the variable that was matched against. The <i>n</i>th element of this array holds the offset of the <i>n</i>th submatch, so <code>$+[1]</code> is the offset past where <code>$1</code> ends, <code>$+[2]</code> the offset past where <code>$2</code> ends, and so on. You can use <code>$#+</code> to determine how many subgroups were in the last successful match. See the examples given for the <code>@-</code> variable.</p> <p>This variable was added in Perl v5.6.0.</p> </dd> <dt id="%LAST_PAREN_MATCH"><a class="permalink" href="#%25LAST_PAREN_MATCH">#</a><a id="LAST_PAREN_MATCH1"></a>%LAST_PAREN_MATCH</dt> <dd> </dd> <dt id="%+"><a class="permalink" href="#%25+">#</a><a id="pod12"></a>%+ </dt> <dd> <p>Similar to <code>@+</code>, the <code>%+</code> hash allows access to the named capture buffers, should they exist, in the last successful match in the currently active dynamic scope.</p> <p>For example, <code>$+{foo}</code> is equivalent to <code>$1</code> after the following match:</p> <pre><code>'foo' =~ /(?<foo>foo)/;</code></pre> <p>The keys of the <code>%+</code> hash list only the names of buffers that have captured (and that are thus associated to defined values).</p> <p>The underlying behaviour of <code>%+</code> is provided by the <a href="/5.18.0/Tie::Hash::NamedCapture">Tie::Hash::NamedCapture</a> module.</p> <p><b>Note:</b> <code>%-</code> and <code>%+</code> are tied views into a common internal hash associated with the last successful regular expression. Therefore mixing iterative access to them via <code>each</code> may have unpredictable results. Likewise, if the last successful match changes, then the results may be surprising.</p> <p>This variable was added in Perl v5.10.0.</p> <p>This variable is read-only and dynamically-scoped.</p> </dd> <dt id="@LAST_MATCH_START"><a class="permalink" href="#@LAST_MATCH_START">#</a><a id="LAST_MATCH_START"></a>@LAST_MATCH_START</dt> <dd> </dd> <dt id="@-"><a class="permalink" href="#@-">#</a><a id="pod13"></a>@- </dt> <dd> <p><code>$-[0]</code> is the offset of the start of the last successful match. <code>$-[</code><i>n</i><code>]</code> is the offset of the start of the substring matched by <i>n</i>-th subpattern, or undef if the subpattern did not match.</p> <p>Thus, after a match against <code>$_</code>, <code>$&</code> coincides with <code>substr $_, $-[0], $+[0] - $-[0]</code>. Similarly, $<i>n</i> coincides with <code>substr $_, $-[n], $+[n] - $-[n]</code> if <code>$-[n]</code> is defined, and $+ coincides with <code>substr $_, $-[$#-], $+[$#-] - $-[$#-]</code>. One can use <code>$#-</code> to find the last matched subgroup in the last successful match. Contrast with <code>$#+</code>, the number of subgroups in the regular expression. Compare with <code>@+</code>.</p> <p>This array holds the offsets of the beginnings of the last successful submatches in the currently active dynamic scope. <code>$-[0]</code> is the offset into the string of the beginning of the entire match. The <i>n</i>th element of this array holds the offset of the <i>n</i>th submatch, so <code>$-[1]</code> is the offset where <code>$1</code> begins, <code>$-[2]</code> the offset where <code>$2</code> begins, and so on.</p> <p>After a match against some variable <code>$var</code>:</p> <dl> <dt id="$`-is-the-same-as-substr($var,-0,-$-[0])"><a class="permalink" href="#$%60-is-the-same-as-substr($var,-0,-$-%5B0%5D)">#</a><a id="is-the-same-as-substr-var-0---0"></a><code>$`</code> is the same as <code>substr($var, 0, $-[0])</code></dt> <dd> </dd> <dt id="$&-is-the-same-as-substr($var,-$-[0],-$+[0]-$-[0])"><a class="permalink" href="#$&-is-the-same-as-substr($var,-$-%5B0%5D,-$+%5B0%5D-$-%5B0%5D)">#</a><a id="is-the-same-as-substr-var---0-0-----0"></a><code>$&</code> is the same as <code>substr($var, $-[0], $+[0] - $-[0])</code></dt> <dd> </dd> <dt id="$'-is-the-same-as-substr($var,-$+[0])"><a class="permalink" href="#$'-is-the-same-as-substr($var,-$+%5B0%5D)">#</a><a id="is-the-same-as-substr-var-0"></a><code>$'</code> is the same as <code>substr($var, $+[0])</code></dt> <dd> </dd> <dt id="$1-is-the-same-as-substr($var,-$-[1],-$+[1]-$-[1])"><a class="permalink" href="#$1-is-the-same-as-substr($var,-$-%5B1%5D,-$+%5B1%5D-$-%5B1%5D)">#</a><a id="is-the-same-as-substr-var---1-1-----1"></a><code>$1</code> is the same as <code>substr($var, $-[1], $+[1] - $-[1])</code></dt> <dd> </dd> <dt id="$2-is-the-same-as-substr($var,-$-[2],-$+[2]-$-[2])"><a class="permalink" href="#$2-is-the-same-as-substr($var,-$-%5B2%5D,-$+%5B2%5D-$-%5B2%5D)">#</a><a id="is-the-same-as-substr-var---2-2-----2"></a><code>$2</code> is the same as <code>substr($var, $-[2], $+[2] - $-[2])</code></dt> <dd> </dd> <dt id="$3-is-the-same-as-substr($var,-$-[3],-$+[3]-$-[3])"><a class="permalink" href="#$3-is-the-same-as-substr($var,-$-%5B3%5D,-$+%5B3%5D-$-%5B3%5D)">#</a><a id="is-the-same-as-substr-var---3-3-----3"></a><code>$3</code> is the same as <code>substr($var, $-[3], $+[3] - $-[3])</code></dt> <dd> </dd> </dl> <p>This variable was added in Perl v5.6.0.</p> </dd> <dt id="%LAST_MATCH_START"><a class="permalink" href="#%25LAST_MATCH_START">#</a><a id="LAST_MATCH_START1"></a>%LAST_MATCH_START</dt> <dd> </dd> <dt id="%-"><a class="permalink" href="#%25-">#</a><a id="pod14"></a>%- </dt> <dd> <p>Similar to <code>%+</code>, this variable allows access to the named capture groups in the last successful match in the currently active dynamic scope. To each capture group name found in the regular expression, it associates a reference to an array containing the list of values captured by all buffers with that name (should there be several of them), in the order where they appear.</p> <p>Here's an example:</p> <pre><code>if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) { foreach my $bufname (sort keys %-) { my $ary = $-{$bufname}; foreach my $idx (0..$#$ary) { print "\$-{$bufname}[$idx] : ", (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"), "\n"; } } }</code></pre> <p>would print out:</p> <pre><code class="plaintext">$-{A}[0] : '1' $-{A}[1] : '3' $-{B}[0] : '2' $-{B}[1] : '4'</code></pre> <p>The keys of the <code>%-</code> hash correspond to all buffer names found in the regular expression.</p> <p>The behaviour of <code>%-</code> is implemented via the <a href="/5.18.0/Tie::Hash::NamedCapture">Tie::Hash::NamedCapture</a> module.</p> <p><b>Note:</b> <code>%-</code> and <code>%+</code> are tied views into a common internal hash associated with the last successful regular expression. Therefore mixing iterative access to them via <code>each</code> may have unpredictable results. Likewise, if the last successful match changes, then the results may be surprising.</p> <p>This variable was added in Perl v5.10.0.</p> <p>This variable is read-only and dynamically-scoped.</p> </dd> <dt id="$LAST_REGEXP_CODE_RESULT"><a class="permalink" href="#$LAST_REGEXP_CODE_RESULT">#</a><a id="LAST_REGEXP_CODE_RESULT"></a>$LAST_REGEXP_CODE_RESULT</dt> <dd> </dd> <dt id="$^R"><a class="permalink" href="#$%5ER">#</a><a id="R"></a>$^R </dt> <dd> <p>The result of evaluation of the last successful <code>(?{ code })</code> regular expression assertion (see <a href="/5.18.0/perlre">perlre</a>). May be written to.</p> <p>This variable was added in Perl 5.005.</p> </dd> <dt id="${^RE_DEBUG_FLAGS}"><a class="permalink" href="#$%7B%5ERE_DEBUG_FLAGS%7D">#</a><a id="RE_DEBUG_FLAGS"></a>${^RE_DEBUG_FLAGS} </dt> <dd> <p>The current value of the regex debugging flags. Set to 0 for no debug output even when the <code>re 'debug'</code> module is loaded. See <a href="/5.18.0/re">re</a> for details.</p> <p>This variable was added in Perl v5.10.0.</p> </dd> <dt id="${^RE_TRIE_MAXBUF}"><a class="permalink" href="#$%7B%5ERE_TRIE_MAXBUF%7D">#</a><a id="RE_TRIE_MAXBUF"></a>${^RE_TRIE_MAXBUF} </dt> <dd> <p>Controls how certain regex optimisations are applied and how much memory they utilize. This value by default is 65536 which corresponds to a 512kB temporary cache. Set this to a higher value to trade memory for speed when matching large alternations. Set it to a lower value if you want the optimisations to be as conservative of memory as possible but still occur, and set it to a negative value to prevent the optimisation and conserve the most memory. Under normal situations this variable should be of no interest to you.</p> <p>This variable was added in Perl v5.10.0.</p> </dd> </dl> <h2 id="Variables-related-to-filehandles"><a class="permalink" href="#Variables-related-to-filehandles">#</a><a id="Variables1"></a>Variables related to filehandles</h2> <p>Variables that depend on the currently selected filehandle may be set by calling an appropriate object method on the <code>IO::Handle</code> object, although this is less efficient than using the regular built-in variables. (Summary lines below for this contain the word HANDLE.) First you must say</p> <pre><code>use IO::Handle;</code></pre> <p>after which you may use either</p> <pre><code class="plaintext">method HANDLE EXPR</code></pre> <p>or more safely,</p> <pre><code>HANDLE->method(EXPR)</code></pre> <p>Each method returns the old value of the <code>IO::Handle</code> attribute. The methods each take an optional EXPR, which, if supplied, specifies the new value for the <code>IO::Handle</code> attribute in question. If not supplied, most methods do nothing to the current value--except for <code>autoflush()</code>, which will assume a 1 for you, just to be different.</p> <p>Because loading in the <code>IO::Handle</code> class is an expensive operation, you should learn how to use the regular built-in variables.</p> <p>A few of these variables are considered "read-only". This means that if you try to assign to this variable, either directly or indirectly through a reference, you'll raise a run-time exception.</p> <p>You should be very careful when modifying the default values of most special variables described in this document. In most cases you want to localize these variables before changing them, since if you don't, the change may affect other modules which rely on the default values of the special variables that you have changed. This is one of the correct ways to read the whole file at once:</p> <pre><code>open my $fh, "<", "foo" or die $!; local $/; # enable localized slurp mode my $content = <$fh>; close $fh;</code></pre> <p>But the following code is quite bad:</p> <pre><code>open my $fh, "<", "foo" or die $!; undef $/; # enable slurp mode my $content = <$fh>; close $fh;</code></pre> <p>since some other module, may want to read data from some file in the default "line mode", so if the code we have just presented has been executed, the global value of <code>$/</code> is now changed for any other code running inside the same Perl interpreter.</p> <p>Usually when a variable is localized you want to make sure that this change affects the shortest scope possible. So unless you are already inside some short <code>{}</code> block, you should create one yourself. For example:</p> <pre><code> my $content = ''; open my $fh, "<", "foo" or die $!; { local $/; $content = <$fh>; } close $fh;</code></pre> <p>Here is an example of how your own code can go broken:</p> <pre><code> for ( 1..3 ){ $\ = "\r\n"; nasty_break(); print "$_"; } sub nasty_break { $\ = "\f"; # do something with $_ }</code></pre> <p>You probably expect this code to print the equivalent of</p> <pre><code class="plaintext">"1\r\n2\r\n3\r\n"</code></pre> <p>but instead you get:</p> <pre><code class="plaintext">"1\f2\f3\f"</code></pre> <p>Why? Because <code>nasty_break()</code> modifies <code>$\</code> without localizing it first. The value you set in <code>nasty_break()</code> is still there when you return. The fix is to add <code>local()</code> so the value doesn't leak out of <code>nasty_break()</code>:</p> <pre><code>local $\ = "\f";</code></pre> <p>It's easy to notice the problem in such a short example, but in more complicated code you are looking for trouble if you don't localize changes to the special variables.</p> <dl> <dt id="$ARGV"><a class="permalink" href="#$ARGV">#</a><a id="ARGV1"></a>$ARGV </dt> <dd> <p>Contains the name of the current file when reading from <code><></code>.</p> </dd> <dt id="@ARGV"><a class="permalink" href="#@ARGV">#</a><a id="ARGV2"></a>@ARGV </dt> <dd> <p>The array <code>@ARGV</code> contains the command-line arguments intended for the script. <code>$#ARGV</code> is generally the number of arguments minus one, because <code>$ARGV[0]</code> is the first argument, <i>not</i> the program's command name itself. See <a href="#%240">"$0"</a> for the command name.</p> </dd> <dt id="ARGV"><a class="permalink" href="#ARGV">#</a>ARGV </dt> <dd> <p>The special filehandle that iterates over command-line filenames in <code>@ARGV</code>. Usually written as the null filehandle in the angle operator <code><></code>. Note that currently <code>ARGV</code> only has its magical effect within the <code><></code> operator; elsewhere it is just a plain filehandle corresponding to the last file opened by <code><></code>. In particular, passing <code>\*ARGV</code> as a parameter to a function that expects a filehandle may not cause your function to automatically read the contents of all the files in <code>@ARGV</code>.</p> </dd> <dt id="ARGVOUT"><a class="permalink" href="#ARGVOUT">#</a>ARGVOUT </dt> <dd> <p>The special filehandle that points to the currently open output file when doing edit-in-place processing with <b>-i</b>. Useful when you have to do a lot of inserting and don't want to keep modifying <code>$_</code>. See <a href="/5.18.0/perlrun">perlrun</a> for the <b>-i</b> switch.</p> </dd> <dt id="IO::Handle->output_field_separator(-EXPR-)"><a class="permalink" href="#IO::Handle-%3Eoutput_field_separator(-EXPR-)">#</a><a id="IO"></a><a id="IO::Handle-output_field_separator-EXPR"></a>IO::Handle->output_field_separator( EXPR )</dt> <dd> </dd> <dt id="$OUTPUT_FIELD_SEPARATOR"><a class="permalink" href="#$OUTPUT_FIELD_SEPARATOR">#</a><a id="OUTPUT_FIELD_SEPARATOR"></a>$OUTPUT_FIELD_SEPARATOR</dt> <dd> </dd> <dt id="$OFS"><a class="permalink" href="#$OFS">#</a><a id="OFS"></a>$OFS</dt> <dd> </dd> <dt id="$,"><a class="permalink" href="#$,">#</a><a id="pod15"></a>$, </dt> <dd> <p>The output field separator for the print operator. If defined, this value is printed between each of print's arguments. Default is <code>undef</code>.</p> <p>You cannot call <code>output_field_separator()</code> on a handle, only as a static method. See <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> <p>Mnemonic: what is printed when there is a "," in your print statement.</p> </dd> <dt id="HANDLE->input_line_number(-EXPR-)"><a class="permalink" href="#HANDLE-%3Einput_line_number(-EXPR-)">#</a><a id="HANDLE"></a><a id="HANDLE-input_line_number-EXPR"></a>HANDLE->input_line_number( EXPR )</dt> <dd> </dd> <dt id="$INPUT_LINE_NUMBER"><a class="permalink" href="#$INPUT_LINE_NUMBER">#</a><a id="INPUT_LINE_NUMBER"></a>$INPUT_LINE_NUMBER</dt> <dd> </dd> <dt id="$NR"><a class="permalink" href="#$NR">#</a><a id="NR"></a>$NR</dt> <dd> </dd> <dt id="$."><a class="permalink" href="#$.">#</a><a id="pod16"></a>$. </dt> <dd> <p>Current line number for the last filehandle accessed.</p> <p>Each filehandle in Perl counts the number of lines that have been read from it. (Depending on the value of <code>$/</code>, Perl's idea of what constitutes a line may not match yours.) When a line is read from a filehandle (via <code>readline()</code> or <code><></code>), or when <code>tell()</code> or <code>seek()</code> is called on it, <code>$.</code> becomes an alias to the line counter for that filehandle.</p> <p>You can adjust the counter by assigning to <code>$.</code>, but this will not actually move the seek pointer. <i>Localizing <code>$.</code> will not localize the filehandle's line count</i>. Instead, it will localize perl's notion of which filehandle <code>$.</code> is currently aliased to.</p> <p><code>$.</code> is reset when the filehandle is closed, but <b>not</b> when an open filehandle is reopened without an intervening <code>close()</code>. For more details, see <a href="/5.18.0/perlop#I%2FO-Operators">"I/O Operators" in perlop</a>. Because <code><></code> never does an explicit close, line numbers increase across <code>ARGV</code> files (but see examples in <a href="/5.18.0/perlfunc#eof">"eof" in perlfunc</a>).</p> <p>You can also use <code>HANDLE->input_line_number(EXPR)</code> to access the line counter for a given filehandle without having to worry about which handle you last accessed.</p> <p>Mnemonic: many programs use "." to mean the current line number.</p> </dd> <dt id="IO::Handle->input_record_separator(-EXPR-)"><a class="permalink" href="#IO::Handle-%3Einput_record_separator(-EXPR-)">#</a><a id="IO1"></a><a id="IO::Handle-input_record_separator-EXPR"></a>IO::Handle->input_record_separator( EXPR )</dt> <dd> </dd> <dt id="$INPUT_RECORD_SEPARATOR"><a class="permalink" href="#$INPUT_RECORD_SEPARATOR">#</a><a id="INPUT_RECORD_SEPARATOR"></a>$INPUT_RECORD_SEPARATOR</dt> <dd> </dd> <dt id="$RS"><a class="permalink" href="#$RS">#</a><a id="RS"></a>$RS</dt> <dd> </dd> <dt id="$/"><a class="permalink" href="#$/">#</a><a id="pod17"></a>$/ </dt> <dd> <p>The input record separator, newline by default. This influences Perl's idea of what a "line" is. Works like <b>awk</b>'s RS variable, including treating empty lines as a terminator if set to the null string (an empty line cannot contain any spaces or tabs). You may set it to a multi-character string to match a multi-character terminator, or to <code>undef</code> to read through the end of file. Setting it to <code>"\n\n"</code> means something slightly different than setting to <code>""</code>, if the file contains consecutive empty lines. Setting to <code>""</code> will treat two or more consecutive empty lines as a single empty line. Setting to <code>"\n\n"</code> will blindly assume that the next input character belongs to the next paragraph, even if it's a newline.</p> <pre><code>local $/; # enable "slurp" mode local $_ = <FH>; # whole file now here s/\n[ \t]+/ /g;</code></pre> <p>Remember: the value of <code>$/</code> is a string, not a regex. <b>awk</b> has to be better for something. :-)</p> <p>Setting <code>$/</code> to a reference to an integer, scalar containing an integer, or scalar that's convertible to an integer will attempt to read records instead of lines, with the maximum record size being the referenced integer number of characters. So this:</p> <pre><code>local $/ = \32768; # or \"32768", or \$var_containing_32768 open my $fh, "<", $myfile or die $!; local $_ = <$fh>;</code></pre> <p>will read a record of no more than 32768 characters from $fh. If you're not reading from a record-oriented file (or your OS doesn't have record-oriented files), then you'll likely get a full chunk of data with every read. If a record is larger than the record size you've set, you'll get the record back in pieces. Trying to set the record size to zero or less will cause reading in the (rest of the) whole file.</p> <p>On VMS only, record reads bypass PerlIO layers and any associated buffering, so you must not mix record and non-record reads on the same filehandle. Record mode mixes with line mode only when the same buffering layer is in use for both modes.</p> <p>You cannot call <code>input_record_separator()</code> on a handle, only as a static method. See <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> <p>See also <a href="/5.18.0/perlport#Newlines">"Newlines" in perlport</a>. Also see <a href="#%24.">"$."</a>.</p> <p>Mnemonic: / delimits line boundaries when quoting poetry.</p> </dd> <dt id="IO::Handle->output_record_separator(-EXPR-)"><a class="permalink" href="#IO::Handle-%3Eoutput_record_separator(-EXPR-)">#</a><a id="IO2"></a><a id="IO::Handle-output_record_separator-EXPR"></a>IO::Handle->output_record_separator( EXPR )</dt> <dd> </dd> <dt id="$OUTPUT_RECORD_SEPARATOR"><a class="permalink" href="#$OUTPUT_RECORD_SEPARATOR">#</a><a id="OUTPUT_RECORD_SEPARATOR"></a>$OUTPUT_RECORD_SEPARATOR</dt> <dd> </dd> <dt id="$ORS"><a class="permalink" href="#$ORS">#</a><a id="ORS"></a>$ORS</dt> <dd> </dd> <dt id="$\"><a class="permalink" href="#$%5C">#</a><a id="pod18"></a>$\ </dt> <dd> <p>The output record separator for the print operator. If defined, this value is printed after the last of print's arguments. Default is <code>undef</code>.</p> <p>You cannot call <code>output_record_separator()</code> on a handle, only as a static method. See <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> <p>Mnemonic: you set <code>$\</code> instead of adding "\n" at the end of the print. Also, it's just like <code>$/</code>, but it's what you get "back" from Perl.</p> </dd> <dt id="HANDLE->autoflush(-EXPR-)"><a class="permalink" href="#HANDLE-%3Eautoflush(-EXPR-)">#</a><a id="HANDLE1"></a><a id="HANDLE-autoflush-EXPR"></a>HANDLE->autoflush( EXPR )</dt> <dd> </dd> <dt id="$OUTPUT_AUTOFLUSH"><a class="permalink" href="#$OUTPUT_AUTOFLUSH">#</a><a id="OUTPUT_AUTOFLUSH"></a>$OUTPUT_AUTOFLUSH</dt> <dd> </dd> <dt id="$|"><a class="permalink" href="#$%7C">#</a><a id="pod19"></a>$| </dt> <dd> <p>If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; <code>$|</code> tells you only whether you've asked Perl explicitly to flush after each write). STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe or socket, such as when you are running a Perl program under <b>rsh</b> and want to see the output as it's happening. This has no effect on input buffering. See <a href="/5.18.0/perlfunc#getc">"getc" in perlfunc</a> for that. See <a href="/5.18.0/perlfunc#select">"select" in perlfunc</a> on how to select the output channel. See also <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> <p>Mnemonic: when you want your pipes to be piping hot.</p> </dd> <dt id="${^LAST_FH}"><a class="permalink" href="#$%7B%5ELAST_FH%7D">#</a><a id="LAST_FH"></a>${^LAST_FH} </dt> <dd> <p>This read-only variable contains a reference to the last-read filehandle. This is set by <code><HANDLE></code>, <code>readline</code>, <code>tell</code>, <code>eof</code> and <code>seek</code>. This is the same handle that <code>$.</code> and <code>tell</code> and <code>eof</code> without arguments use. It is also the handle used when Perl appends ", <STDIN> line 1" to an error or warning message.</p> <p>This variable was added in Perl v5.18.0.</p> </dd> </dl> <h3 id="Variables-related-to-formats"><a class="permalink" href="#Variables-related-to-formats">#</a><a id="Variables2"></a>Variables related to formats</h3> <p>The special variables for formats are a subset of those for filehandles. See <a href="/5.18.0/perlform">perlform</a> for more information about Perl's formats.</p> <dl> <dt id="$ACCUMULATOR"><a class="permalink" href="#$ACCUMULATOR">#</a><a id="ACCUMULATOR"></a>$ACCUMULATOR</dt> <dd> </dd> <dt id="$^A"><a class="permalink" href="#$%5EA">#</a><a id="A"></a>$^A </dt> <dd> <p>The current value of the <code>write()</code> accumulator for <code>format()</code> lines. A format contains <code>formline()</code> calls that put their result into <code>$^A</code>. After calling its format, <code>write()</code> prints out the contents of <code>$^A</code> and empties. So you never really see the contents of <code>$^A</code> unless you call <code>formline()</code> yourself and then look at it. See <a href="/5.18.0/perlform">perlform</a> and <a href="/5.18.0/perlfunc#formline-PICTURE%2CLIST">"formline PICTURE,LIST" in perlfunc</a>.</p> </dd> <dt id="IO::Handle->format_formfeed(EXPR)"><a class="permalink" href="#IO::Handle-%3Eformat_formfeed(EXPR)">#</a><a id="IO3"></a><a id="IO::Handle-format_formfeed-EXPR"></a>IO::Handle->format_formfeed(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_FORMFEED"><a class="permalink" href="#$FORMAT_FORMFEED">#</a><a id="FORMAT_FORMFEED"></a>$FORMAT_FORMFEED</dt> <dd> </dd> <dt id="$^L"><a class="permalink" href="#$%5EL">#</a><a id="L"></a>$^L </dt> <dd> <p>What formats output as a form feed. The default is <code>\f</code>.</p> <p>You cannot call <code>format_formfeed()</code> on a handle, only as a static method. See <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> </dd> <dt id="HANDLE->format_page_number(EXPR)"><a class="permalink" href="#HANDLE-%3Eformat_page_number(EXPR)">#</a><a id="HANDLE2"></a><a id="HANDLE-format_page_number-EXPR"></a>HANDLE->format_page_number(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_PAGE_NUMBER"><a class="permalink" href="#$FORMAT_PAGE_NUMBER">#</a><a id="FORMAT_PAGE_NUMBER"></a>$FORMAT_PAGE_NUMBER</dt> <dd> </dd> <dt id="$%"><a class="permalink" href="#$%25">#</a><a id="pod20"></a>$% </dt> <dd> <p>The current page number of the currently selected output channel.</p> <p>Mnemonic: <code>%</code> is page number in <b>nroff</b>.</p> </dd> <dt id="HANDLE->format_lines_left(EXPR)"><a class="permalink" href="#HANDLE-%3Eformat_lines_left(EXPR)">#</a><a id="HANDLE3"></a><a id="HANDLE-format_lines_left-EXPR"></a>HANDLE->format_lines_left(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_LINES_LEFT"><a class="permalink" href="#$FORMAT_LINES_LEFT">#</a><a id="FORMAT_LINES_LEFT"></a>$FORMAT_LINES_LEFT</dt> <dd> </dd> <dt id="$-"><a class="permalink" href="#$-">#</a><a id="pod21"></a>$- </dt> <dd> <p>The number of lines left on the page of the currently selected output channel.</p> <p>Mnemonic: lines_on_page - lines_printed.</p> </dd> <dt id="IO::Handle->format_line_break_characters-EXPR"><a class="permalink" href="#IO::Handle-%3Eformat_line_break_characters-EXPR">#</a><a id="IO4"></a><a id="IO::Handle-format_line_break_characters-EXPR"></a>IO::Handle->format_line_break_characters EXPR</dt> <dd> </dd> <dt id="$FORMAT_LINE_BREAK_CHARACTERS"><a class="permalink" href="#$FORMAT_LINE_BREAK_CHARACTERS">#</a><a id="FORMAT_LINE_BREAK_CHARACTERS"></a>$FORMAT_LINE_BREAK_CHARACTERS</dt> <dd> </dd> <dt id="$:"><a class="permalink" href="#$:">#</a><a id="pod22"></a>$: </dt> <dd> <p>The current set of characters after which a string may be broken to fill continuation fields (starting with <code>^</code>) in a format. The default is <span style="white-space: nowrap;">" \n-"</span>, to break on a space, newline, or a hyphen.</p> <p>You cannot call <code>format_line_break_characters()</code> on a handle, only as a static method. See <a href="/5.18.0/IO::Handle">IO::Handle</a>.</p> <p>Mnemonic: a "colon" in poetry is a part of a line.</p> </dd> <dt id="HANDLE->format_lines_per_page(EXPR)"><a class="permalink" href="#HANDLE-%3Eformat_lines_per_page(EXPR)">#</a><a id="HANDLE4"></a><a id="HANDLE-format_lines_per_page-EXPR"></a>HANDLE->format_lines_per_page(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_LINES_PER_PAGE"><a class="permalink" href="#$FORMAT_LINES_PER_PAGE">#</a><a id="FORMAT_LINES_PER_PAGE"></a>$FORMAT_LINES_PER_PAGE</dt> <dd> </dd> <dt id="$="><a class="permalink" href="#$=">#</a><a id="pod23"></a>$= </dt> <dd> <p>The current page length (printable lines) of the currently selected output channel. The default is 60.</p> <p>Mnemonic: = has horizontal lines.</p> </dd> <dt id="HANDLE->format_top_name(EXPR)"><a class="permalink" href="#HANDLE-%3Eformat_top_name(EXPR)">#</a><a id="HANDLE5"></a><a id="HANDLE-format_top_name-EXPR"></a>HANDLE->format_top_name(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_TOP_NAME"><a class="permalink" href="#$FORMAT_TOP_NAME">#</a><a id="FORMAT_TOP_NAME"></a>$FORMAT_TOP_NAME</dt> <dd> </dd> <dt id="$^"><a class="permalink" href="#$%5E">#</a><a id="pod24"></a>$^ </dt> <dd> <p>The name of the current top-of-page format for the currently selected output channel. The default is the name of the filehandle with <code>_TOP</code> appended. For example, the default format top name for the <code>STDOUT</code> filehandle is <code>STDOUT_TOP</code>.</p> <p>Mnemonic: points to top of page.</p> </dd> <dt id="HANDLE->format_name(EXPR)"><a class="permalink" href="#HANDLE-%3Eformat_name(EXPR)">#</a><a id="HANDLE6"></a><a id="HANDLE-format_name-EXPR"></a>HANDLE->format_name(EXPR)</dt> <dd> </dd> <dt id="$FORMAT_NAME"><a class="permalink" href="#$FORMAT_NAME">#</a><a id="FORMAT_NAME"></a>$FORMAT_NAME</dt> <dd> </dd> <dt id="$~"><a class="permalink" href="#$~">#</a><a id="pod25"></a>$~ </dt> <dd> <p>The name of the current report format for the currently selected output channel. The default format name is the same as the filehandle name. For example, the default format name for the <code>STDOUT</code> filehandle is just <code>STDOUT</code>.</p> <p>Mnemonic: brother to <code>$^</code>.</p> </dd> </dl> <h2 id="Error-Variables"><a class="permalink" href="#Error-Variables">#</a><a id="Error"></a>Error Variables </h2> <p>The variables <code>$@</code>, <code>$!</code>, <code>$^E</code>, and <code>$?</code> contain information about different types of error conditions that may appear during execution of a Perl program. The variables are shown ordered by the "distance" between the subsystem which reported the error and the Perl process. They correspond to errors detected by the Perl interpreter, C library, operating system, or an external program, respectively.</p> <p>To illustrate the differences between these variables, consider the following Perl expression, which uses a single-quoted string. After execution of this statement, perl may have set all four special error variables:</p> <pre><code> eval q{ open my $pipe, "/cdrom/install |" or die $!; my @res = <$pipe>; close $pipe or die "bad pipe: $?, $!"; };</code></pre> <p>When perl executes the <code>eval()</code> expression, it translates the <code>open()</code>, <code><PIPE></code>, and <code>close</code> calls in the C run-time library and thence to the operating system kernel. perl sets <code>$!</code> to the C library's <code>errno</code> if one of these calls fails.</p> <p><code>$@</code> is set if the string to be <code>eval</code>-ed did not compile (this may happen if <code>open</code> or <code>close</code> were imported with bad prototypes), or if Perl code executed during evaluation <code>die()</code>d. In these cases the value of <code>$@</code> is the compile error, or the argument to <code>die</code> (which will interpolate <code>$!</code> and <code>$?</code>). (See also <a href="/5.18.0/Fatal">Fatal</a>, though.)</p> <p>Under a few operating systems, <code>$^E</code> may contain a more verbose error indicator, such as in this case, "CDROM tray not closed." Systems that do not support extended error messages leave <code>$^E</code> the same as <code>$!</code>.</p> <p>Finally, <code>$?</code> may be set to non-0 value if the external program <i>/cdrom/install</i> fails. The upper eight bits reflect specific error conditions encountered by the program (the program's <code>exit()</code> value). The lower eight bits reflect mode of failure, like signal death and core dump information. See <a href="http://man.he.net/man2/wait">wait(2)</a> for details. In contrast to <code>$!</code> and <code>$^E</code>, which are set only if error condition is detected, the variable <code>$?</code> is set on each <code>wait</code> or pipe <code>close</code>, overwriting the old value. This is more like <code>$@</code>, which on every <code>eval()</code> is always set on failure and cleared on success.</p> <p>For more details, see the individual descriptions at <code>$@</code>, <code>$!</code>, <code>$^E</code>, and <code>$?</code>.</p> <dl> <dt id="${^CHILD_ERROR_NATIVE}"><a class="permalink" href="#$%7B%5ECHILD_ERROR_NATIVE%7D">#</a><a id="CHILD_ERROR_NATIVE"></a>${^CHILD_ERROR_NATIVE} </dt> <dd> <p>The native status returned by the last pipe close, backtick (<code>``</code>) command, successful call to <code>wait()</code> or <code>waitpid()</code>, or from the <code>system()</code> operator. On POSIX-like systems this value can be decoded with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG and WIFCONTINUED functions provided by the <a href="/5.18.0/POSIX">POSIX</a> module.</p> <p>Under VMS this reflects the actual VMS exit status; i.e. it is the same as <code>$?</code> when the pragma <code>use vmsish 'status'</code> is in effect.</p> <p>This variable was added in Perl v5.10.0.</p> </dd> <dt id="$EXTENDED_OS_ERROR"><a class="permalink" href="#$EXTENDED_OS_ERROR">#</a><a id="EXTENDED_OS_ERROR"></a>$EXTENDED_OS_ERROR</dt> <dd> </dd> <dt id="$^E"><a class="permalink" href="#$%5EE">#</a><a id="E"></a>$^E </dt> <dd> <p>Error information specific to the current operating system. At the moment, this differs from <code>$!</code> under only VMS, OS/2, and Win32 (and for MacPerl). On all other platforms, <code>$^E</code> is always just the same as <code>$!</code>.</p> <p>Under VMS, <code>$^E</code> provides the VMS status value from the last system error. This is more specific information about the last system error than that provided by <code>$!</code>. This is particularly important when <code>$!</code> is set to <b>EVMSERR</b>.</p> <p>Under OS/2, <code>$^E</code> is set to the error code of the last call to OS/2 API either via CRT, or directly from perl.</p> <p>Under Win32, <code>$^E</code> always returns the last error information reported by the Win32 call <code>GetLastError()</code> which describes the last error from within the Win32 API. Most Win32-specific code will report errors via <code>$^E</code>. ANSI C and Unix-like calls set <code>errno</code> and so most portable Perl code will report errors via <code>$!</code>.</p> <p>Caveats mentioned in the description of <code>$!</code> generally apply to <code>$^E</code>, also.</p> <p>This variable was added in Perl 5.003.</p> <p>Mnemonic: Extra error explanation.</p> </dd> <dt id="$EXCEPTIONS_BEING_CAUGHT"><a class="permalink" href="#$EXCEPTIONS_BEING_CAUGHT">#</a><a id="EXCEPTIONS_BEING_CAUGHT"></a>$EXCEPTIONS_BEING_CAUGHT</dt> <dd> </dd> <dt id="$^S"><a class="permalink" href="#$%5ES">#</a><a id="S"></a>$^S </dt> <dd> <p>Current state of the interpreter.</p> <pre><code class="plaintext">$^S State --------- ------------------------------------- undef Parsing module, eval, or main program true (1) Executing an eval false (0) Otherwise</code></pre> <p>The first state may happen in <code>$SIG{__DIE__}</code> and <code>$SIG{__WARN__}</code> handlers.</p> <p>The English name $EXCEPTIONS_BEING_CAUGHT is slightly misleading, because the <code>undef</code> value does not indicate whether exceptions are being caught, since compilation of the main program does not catch exceptions.</p> <p>This variable was added in Perl 5.004.</p> </dd> <dt id="$WARNING"><a class="permalink" href="#$WARNING">#</a><a id="WARNING"></a>$WARNING</dt> <dd> </dd> <dt id="$^W"><a class="permalink" href="#$%5EW">#</a><a id="W"></a>$^W </dt> <dd> <p>The current value of the warning switch, initially true if <b>-w</b> was used, false otherwise, but directly modifiable.</p> <p>See also <a href="/5.18.0/warnings">warnings</a>.</p> <p>Mnemonic: related to the <b>-w</b> switch.</p> </dd> <dt id="${^WARNING_BITS}"><a class="permalink" href="#$%7B%5EWARNING_BITS%7D">#</a><a id="WARNING_BITS"></a>${^WARNING_BITS} </dt> <dd> <p>The current set of warning checks enabled by the <code>use warnings</code> pragma. It has the same scoping as the <code>$^H</code> and <code>%^H</code> variables. The exact values are considered internal to the <a href="/5.18.0/warnings">warnings</a> pragma and may change between versions of Perl.</p> <p>This variable was added in Perl v5.6.0.</p> </dd> <dt id="$OS_ERROR"><a class="permalink" href="#$OS_ERROR">#</a><a id="OS_ERROR"></a>$OS_ERROR</dt> <dd> </dd> <dt id="$ERRNO"><a class="permalink" href="#$ERRNO">#</a><a id="ERRNO"></a>$ERRNO</dt> <dd> </dd> <dt id="$!"><a class="permalink" href="#$!">#</a><a id="pod26"></a>$! </dt> <dd> <p>When referenced, <code>$!</code> retrieves the current value of the C <code>errno</code> integer variable. If <code>$!</code> is assigned a numerical value, that value is stored in <code>errno</code>. When referenced as a string, <code>$!</code> yields the system error string corresponding to <code>errno</code>.</p> <p>Many system or library calls set <code>errno</code> if they fail, to indicate the cause of failure. They usually do <b>not</b> set <code>errno</code> to zero if they succeed. This means <code>errno</code>, hence <code>$!</code>, is meaningful only <i>immediately</i> after a <b>failure</b>:</p> <pre><code> if (open my $fh, "<", $filename) { # Here $! is meaningless. ... } else { # ONLY here is $! meaningful. ... # Already here $! might be meaningless. } # Since here we might have either success or failure, # $! is meaningless.</code></pre> <p>Here, <i>meaningless</i> means that <code>$!</code> may be unrelated to the outcome of the <code>open()</code> operator. Assignment to <code>$!</code> is similarly ephemeral. It can be used immediately before invoking the <code>die()</code> operator, to set the exit value, or to inspect the system error string corresponding to error <i>n</i>, or to restore <code>$!</code> to a meaningful state.</p> <p>Mnemonic: What just went bang?</p> </dd> <dt id="%OS_ERROR"><a class="permalink" href="#%25OS_ERROR">#</a><a id="OS_ERROR1"></a>%OS_ERROR</dt> <dd> </dd> <dt id="%ERRNO"><a class="permalink" href="#%25ERRNO">#</a><a id="ERRNO1"></a>%ERRNO</dt> <dd> </dd> <dt id="%!"><a class="permalink" href="#%25!">#</a><a id="pod27"></a>%! </dt> <dd> <p>Each element of <code>%!</code> has a true value only if <code>$!</code> is set to that value. For example, <code>$!{ENOENT}</code> is true if and only if the current value of <code>$!</code> is <code>ENOENT</code>; that is, if the most recent error was "No such file or directory" (or its moral equivalent: not all operating systems give that exact error, and certainly not all languages). To check if a particular key is meaningful on your system, use <code>exists $!{the_key}</code>; for a list of legal keys, use <code>keys %!</code>. See <a href="/5.18.0/Errno">Errno</a> for more information, and also see <a href="#%24!">"$!"</a>.</p> <p>This variable was added in Perl 5.005.</p> </dd> <dt id="$CHILD_ERROR"><a class="permalink" href="#$CHILD_ERROR">#</a><a id="CHILD_ERROR"></a>$CHILD_ERROR</dt> <dd> </dd> <dt id="$?"><a class="permalink" href="#$?">#</a><a id="pod28"></a>$? </dt> <dd> <p>The status returned by the last pipe close, backtick (<code>``</code>) command, successful call to <code>wait()</code> or <code>waitpid()</code>, or from the <code>system()</code> operator. This is just the 16-bit status word returned by the traditional Unix <code>wait()</code> system call (or else is made up to look like it). Thus, the exit value of the subprocess is really (<code>$? >> 8</code>), and <code>$? & 127</code> gives which signal, if any, the process died from, and <code>$? & 128</code> reports whether there was a core dump.</p> <p>Additionally, if the <code>h_errno</code> variable is supported in C, its value is returned via <code>$?</code> if any <code>gethost*()</code> function fails.</p> <p>If you have installed a signal handler for <code>SIGCHLD</code>, the value of <code>$?</code> will usually be wrong outside that handler.</p> <p>Inside an <code>END</code> subroutine <code>$?</code> contains the value that is going to be given to <code>exit()</code>. You can modify <code>$?</code> in an <code>END</code> subroutine to change the exit status of your program. For example:</p> <pre><code> END { $? = 1 if $? == 255; # die would make it 255 }</code></pre> <p>Under VMS, the pragma <code>use vmsish 'status'</code> makes <code>$?</code> reflect the actual VMS exit status, instead of the default emulation of POSIX status; see <a href="/5.18.0/perlvms#%24%3F">"$?" in perlvms</a> for details.</p> <p>Mnemonic: similar to <b>sh</b> and <b>ksh</b>.</p> </dd> <dt id="$EVAL_ERROR"><a class="permalink" href="#$EVAL_ERROR">#</a><a id="EVAL_ERROR"></a>$EVAL_ERROR</dt> <dd> </dd> <dt id="$@"><a class="permalink" href="#$@">#</a><a id="pod29"></a>$@ </dt> <dd> <p>The Perl syntax error message from the last <code>eval()</code> operator. If <code>$@</code> is the null string, the last <code>eval()</code> parsed and executed correctly (although the operations you invoked may have failed in the normal fashion).</p> <p>Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting <code>$SIG{__WARN__}</code> as described in <a href="#%25SIG">"%SIG"</a>.</p> <p>Mnemonic: Where was the syntax error "at"?</p> </dd> </dl> <h2 id="Variables-related-to-the-interpreter-state"><a class="permalink" href="#Variables-related-to-the-interpreter-state">#</a><a id="Variables3"></a>Variables related to the interpreter state</h2> <p>These variables provide information about the current interpreter state.</p> <dl> <dt id="$COMPILING"><a class="permalink" href="#$COMPILING">#</a><a id="COMPILING"></a>$COMPILING</dt> <dd> </dd> <dt id="$^C"><a class="permalink" href="#$%5EC">#</a><a id="C"></a>$^C </dt> <dd> <p>The current value of the flag associated with the <b>-c</b> switch. Mainly of use with <b>-MO=...</b> to allow code to alter its behavior when being compiled, such as for example to <code>AUTOLOAD</code> at compile time rather than normal, deferred loading. Setting <code>$^C = 1</code> is similar to calling <code>B::minus_c</code>.</p> <p>This variable was added in Perl v5.6.0.</p> </dd> <dt id="$DEBUGGING"><a class="permalink" href="#$DEBUGGING">#</a><a id="DEBUGGING"></a>$DEBUGGING</dt> <dd> </dd> <dt id="$^D"><a class="permalink" href="#$%5ED">#</a><a id="D"></a>$^D </dt> <dd> <p>The current value of the debugging flags. May be read or set. Like its command-line equivalent, you can use numeric or symbolic values, eg <code>$^D = 10</code> or <code>$^D = "st"</code>.</p> <p>Mnemonic: value of <b>-D</b> switch.</p> </dd> <dt id="${^ENCODING}"><a class="permalink" href="#$%7B%5EENCODING%7D">#</a><a id="ENCODING"></a>${^ENCODING} </dt> <dd> <p>The <i>object reference</i> to the <code>Encode</code> object that is used to convert the source code to Unicode. Thanks to this variable your Perl script does not have to be written in UTF-8. Default is <i>undef</i>. The direct manipulation of this variable is highly discouraged.</p> <p>This variable was added in Perl 5.8.2.</p> </dd> <dt id="${^GLOBAL_PHASE}"><a class="permalink" href="#$%7B%5EGLOBAL_PHASE%7D">#</a><a id="GLOBAL_PHASE"></a>${^GLOBAL_PHASE} </dt> <dd> <p>The current phase of the perl interpreter.</p> <p>Possible values are:</p> <dl> <dt id="CONSTRUCT"><a class="permalink" href="#CONSTRUCT">#</a>CONSTRUCT</dt> <dd> <p>The <code>PerlInterpreter*</code> is being constructed via <code>perl_construct</code>. This value is mostly there for completeness and for use via the underlying C variable <code>PL_phase</code>. It's not really possible for Perl code to be executed unless construction of the interpreter is finished.</p> </dd> <dt id="START"><a class="permalink" href="#START">#</a>START</dt> <dd> <p>This is the global compile-time. That includes, basically, every <code>BEGIN</code> block executed directly or indirectly from during the compile-time of the top-level program.</p> <p>This phase is not called "BEGIN" to avoid confusion with <code>BEGIN</code>-blocks, as those are executed during compile-time of any compilation unit, not just the top-level program. A new, localised compile-time entered at run-time, for example by constructs as <code>eval "use SomeModule"</code> are not global interpreter phases, and therefore aren't reflected by <code>${^GLOBAL_PHASE}</code>.</p> </dd> <dt id="CHECK"><a class="permalink" href="#CHECK">#</a>CHECK</dt> <dd> <p>Execution of any <code>CHECK</code> blocks.</p> </dd> <dt id="INIT"><a class="permalink" href="#INIT">#</a>INIT</dt> <dd> <p>Similar to "CHECK", but for <code>INIT</code>-blocks, not <code>CHECK</code> blocks.</p> </dd> <dt id="RUN"><a class="permalink" href="#RUN">#</a>RUN</dt> <dd> <p>The main run-time, i.e. the execution of <code>PL_main_root</code>.</p> </dd> <dt id="END"><a class="permalink" href="#END">#</a>END</dt> <dd> <p>Execution of any <code>END</code> blocks.</p> </dd> <dt id="DESTRUCT"><a class="permalink" href="#DESTRUCT">#</a>DESTRUCT</dt> <dd> <p>Global destruction.</p> </dd> </dl> <p>Also note that there's no value for UNITCHECK-blocks. That's because those are run for each compilation unit individually, and therefore is not a global interpreter phase.</p> <p>Not every program has to go through each of the possible phases, but transition from one phase to another can only happen in the order described in the above list.</p> <p>An example of all of the phases Perl code can see:</p> <pre><code>BEGIN { print "compile-time: ${^GLOBAL_PHASE}\n" } INIT { print "init-time: ${^GLOBAL_PHASE}\n" } CHECK { print "check-time: ${^GLOBAL_PHASE}\n" } { package Print::Phase; sub new { my ($class, $time) = @_; return bless \$time, $class; } sub DESTROY { my $self = shift; print "$$self: ${^GLOBAL_PHASE}\n"; } } print "run-time: ${^GLOBAL_PHASE}\n"; my $runtime = Print::Phase->new( "lexical variables are garbage collected before END" ); END { print "end-time: ${^GLOBAL_PHASE}\n" } our $destruct = Print::Phase->new( "package variables are garbage collected after END" );</code></pre> <p>This will print out</p> <pre><code class="plaintext">compile-time: START check-time: CHECK init-time: INIT run-time: RUN lexical variables are garbage collected before END: RUN end-time: END package variables are garbage collected after END: DESTRUCT</code></pre> <p>This variable was added in Perl 5.14.0.</p> </dd> <dt id="$^H"><a class="permalink" href="#$%5EH">#</a><a id="H"></a>$^H </dt> <dd> <p>WARNING: This variable is strictly for internal use only. Its availability, behavior, and contents are subject to change without notice.</p> <p>This variable contains compile-time hints for the Perl interpreter. At the end of compilation of a BLOCK the value of this variable is restored to the value when the interpreter started to compile the BLOCK.</p> <p>When perl begins to parse any block construct that provides a lexical scope (e.g., eval body, required file, subroutine body, loop body, or conditional block), the existing value of <code>$^H</code> is saved, but its value is left unchanged. When the compilation of the block is completed, it regains the saved value. Between the points where its value is saved and restored, code that executes within BEGIN blocks is free to change the value of <code>$^H</code>.</p> <p>This behavior provides the semantic of lexical scoping, and is used in, for instance, the <code>use strict</code> pragma.</p> <p>The contents should be an integer; different bits of it are used for different pragmatic flags. Here's an example:</p> <pre><code> sub add_100 { $^H |= 0x100 } sub foo { BEGIN { add_100() } bar->baz($boon); }</code></pre> <p>Consider what happens during execution of the BEGIN block. At this point the BEGIN block has already been compiled, but the body of <code>foo()</code> is still being compiled. The new value of <code>$^H</code> will therefore be visible only while the body of <code>foo()</code> is being compiled.</p> <p>Substitution of <code>BEGIN { add_100() }</code> block with:</p> <pre><code>BEGIN { require strict; strict->import('vars') }</code></pre> <p>demonstrates how <code>use strict 'vars'</code> is implemented. Here's a conditional version of the same lexical pragma:</p> <pre><code> BEGIN { require strict; strict->import('vars') if $condition }</code></pre> <p>This variable was added in Perl 5.003.</p> </dd> <dt id="%^H"><a class="permalink" href="#%25%5EH">#</a><a id="H1"></a>%^H </dt> <dd> <p>The <code>%^H</code> hash provides the same scoping semantic as <code>$^H</code>. This makes it useful for implementation of lexically scoped pragmas. See <a href="/5.18.0/perlpragma">perlpragma</a>.</p> <p>When putting items into <code>%^H</code>, in order to avoid conflicting with other users of the hash there is a convention regarding which keys to use. A module should use only keys that begin with the module's name (the name of its main package) and a "/" character. For example, a module <code>Foo::Bar</code> should use keys such as <code>Foo::Bar/baz</code>.</p> <p>This variable was added in Perl v5.6.0.</p> </dd> <dt id="${^OPEN}"><a class="permalink" href="#$%7B%5EOPEN%7D">#</a><a id="OPEN"></a>${^OPEN} </dt> <dd> <p>An internal variable used by PerlIO. A string in two parts, separated by a <code>\0</code> byte, the first part describes the input layers, the second part describes the output layers.</p> <p>This variable was added in Perl v5.8.0.</p> </dd> <dt id="$PERLDB"><a class="permalink" href="#$PERLDB">#</a><a id="PERLDB"></a>$PERLDB</dt> <dd> </dd> <dt id="$^P"><a class="permalink" href="#$%5EP">#</a><a id="P"></a>$^P </dt> <dd> <p>The internal variable for debugging support. The meanings of the various bits are subject to change, but currently indicate:</p> <dl> <dt id="0x01"><a class="permalink" href="#0x01">#</a><a id="x01"></a>0x01</dt> <dd> <p>Debug subroutine enter/exit.</p> </dd> <dt id="0x02"><a class="permalink" href="#0x02">#</a><a id="x02"></a>0x02</dt> <dd> <p>Line-by-line debugging. Causes <code>DB::DB()</code> subroutine to be called for each statement executed. Also causes saving source code lines (like 0x400).</p> </dd> <dt id="0x04"><a class="permalink" href="#0x04">#</a><a id="x04"></a>0x04</dt> <dd> <p>Switch off optimizations.</p> </dd> <dt id="0x08"><a class="permalink" href="#0x08">#</a><a id="x08"></a>0x08</dt> <dd> <p>Preserve more data for future interactive inspections.</p> </dd> <dt id="0x10"><a class="permalink" href="#0x10">#</a><a id="x10"></a>0x10</dt> <dd> <p>Keep info about source lines on which a subroutine is defined.</p> </dd> <dt id="0x20"><a class="permalink" href="#0x20">#</a><a id="x20"></a>0x20</dt> <dd> <p>Start with single-step on.</p> </dd> <dt id="0x40"><a class="permalink" href="#0x40">#</a><a id="x40"></a>0x40</dt> <dd> <p>Use subroutine address instead of name when reporting.</p> </dd> <dt id="0x80"><a class="permalink" href="#0x80">#</a><a id="x80"></a>0x80</dt> <dd> <p>Report <code>goto &subroutine</code> as well.</p> </dd> <dt id="0x100"><a class="permalink" href="#0x100">#</a><a id="x100"></a>0x100</dt> <dd> <p>Provide informative "file" names for evals based on the place they were compiled.</p> </dd> <dt id="0x200"><a class="permalink" href="#0x200">#</a><a id="x200"></a>0x200</dt> <dd> <p>Provide informative names to anonymous subroutines based on the place they were compiled.</p> </dd> <dt id="0x400"><a class="permalink" href="#0x400">#</a><a id="x400"></a>0x400</dt> <dd> <p>Save source code lines into <code>@{"_<$filename"}</code>.</p> </dd> </dl> <p>Some bits may be relevant at compile-time only, some at run-time only. This is a new mechanism and the details may change. See also <a href="/5.18.0/perldebguts">perldebguts</a>.</p> </dd> <dt id="${^TAINT}"><a class="permalink" href="#$%7B%5ETAINT%7D">#</a><a id="TAINT"></a>${^TAINT} </dt> <dd> <p>Reflects if taint mode is on or off. 1 for on (the program was run with <b>-T</b>), 0 for off, -1 when only taint warnings are enabled (i.e. with <b>-t</b> or <b>-TU</b>).</p> <p>This variable is read-only.</p> <p>This variable was added in Perl v5.8.0.</p> </dd> <dt id="${^UNICODE}"><a class="permalink" href="#$%7B%5EUNICODE%7D">#</a><a id="UNICODE"></a>${^UNICODE} </dt> <dd> <p>Reflects certain Unicode settings of Perl. See <a href="/5.18.0/perlrun">perlrun</a> documentation for the <code>-C</code> switch for more information about the possible values.</p> <p>This variable is set during Perl startup and is thereafter read-only.</p> <p>This variable was added in Perl v5.8.2.</p> </dd> <dt id="${^UTF8CACHE}"><a class="permalink" href="#$%7B%5EUTF8CACHE%7D">#</a><a id="UTF8CACHE"></a>${^UTF8CACHE} </dt> <dd> <p>This variable controls the state of the internal UTF-8 offset caching code. 1 for on (the default), 0 for off, -1 to debug the caching code by checking all its results against linear scans, and panicking on any discrepancy.</p> <p>This variable was added in Perl v5.8.9. It is subject to change or removal without notice, but is currently used to avoid recalculating the boundaries of multi-byte UTF-8-encoded characters.</p> </dd> <dt id="${^UTF8LOCALE}"><a class="permalink" href="#$%7B%5EUTF8LOCALE%7D">#</a><a id="UTF8LOCALE"></a>${^UTF8LOCALE} </dt> <dd> <p>This variable indicates whether a UTF-8 locale was detected by perl at startup. This information is used by perl when it's in adjust-utf8ness-to-locale mode (as when run with the <code>-CL</code> command-line switch); see <a href="/5.18.0/perlrun">perlrun</a> for more info on this.</p> <p>This variable was added in Perl v5.8.8.</p> </dd> </dl> <h2 id="Deprecated-and-removed-variables"><a class="permalink" href="#Deprecated-and-removed-variables">#</a><a id="Deprecated"></a>Deprecated and removed variables</h2> <p>Deprecating a variable announces the intent of the perl maintainers to eventually remove the variable from the language. It may still be available despite its status. Using a deprecated variable triggers a warning.</p> <p>Once a variable is removed, its use triggers an error telling you the variable is unsupported.</p> <p>See <a href="/5.18.0/perldiag">perldiag</a> for details about error messages.</p> <dl> <dt id="$OFMT"><a class="permalink" href="#$OFMT">#</a><a id="OFMT"></a>$OFMT</dt> <dd> </dd> <dt id="$#"><a class="permalink" href="#$%23">#</a><a id="pod30"></a>$# </dt> <dd> <p><code>$#</code> was a variable that could be used to format printed numbers. After a deprecation cycle, its magic was removed in Perl v5.10.0 and using it now triggers a warning: <code>$# is no longer supported</code>.</p> <p>This is not the sigil you use in front of an array name to get the last index, like <code>$#array</code>. That's still how you get the last index of an array in Perl. The two have nothing to do with each other.</p> <p>Deprecated in Perl 5.</p> <p>Removed in Perl v5.10.0.</p> </dd> <dt id="$*"><a class="permalink" href="#$*">#</a><a id="pod31"></a>$* </dt> <dd> <p><code>$*</code> was a variable that you could use to enable multiline matching. After a deprecation cycle, its magic was removed in Perl v5.10.0. Using it now triggers a warning: <code>$* is no longer supported</code>. You should use the <code>/s</code> and <code>/m</code> regexp modifiers instead.</p> <p>Deprecated in Perl 5.</p> <p>Removed in Perl v5.10.0.</p> </dd> <dt id="$ARRAY_BASE"><a class="permalink" href="#$ARRAY_BASE">#</a><a id="ARRAY_BASE"></a>$ARRAY_BASE</dt> <dd> </dd> <dt id="$["><a class="permalink" href="#$%5B">#</a><a id="pod32"></a>$[ </dt> <dd> <p>This variable stores the index of the first element in an array, and of the first character in a substring. The default is 0, but you could theoretically set it to 1 to make Perl behave more like <b>awk</b> (or Fortran) when subscripting and when evaluating the index() and substr() functions.</p> <p>As of release 5 of Perl, assignment to <code>$[</code> is treated as a compiler directive, and cannot influence the behavior of any other file. (That's why you can only assign compile-time constants to it.) Its use is highly discouraged.</p> <p>Prior to Perl v5.10.0, assignment to <code>$[</code> could be seen from outer lexical scopes in the same file, unlike other compile-time directives (such as <a href="/5.18.0/strict">strict</a>). Using local() on it would bind its value strictly to a lexical block. Now it is always lexically scoped.</p> <p>As of Perl v5.16.0, it is implemented by the <a href="/5.18.0/arybase">arybase</a> module. See <a href="/5.18.0/arybase">arybase</a> for more details on its behaviour.</p> <p>Under <code>use v5.16</code>, or <code>no feature "array_base"</code>, <code>$[</code> no longer has any effect, and always contains 0. Assigning 0 to it is permitted, but any other value will produce an error.</p> <p>Mnemonic: [ begins subscripts.</p> <p>Deprecated in Perl v5.12.0.</p> </dd> <dt id="$OLD_PERL_VERSION"><a class="permalink" href="#$OLD_PERL_VERSION">#</a><a id="OLD_PERL_VERSION"></a>$OLD_PERL_VERSION</dt> <dd> </dd> <dt id="$]"><a class="permalink" href="#$%5D">#</a><a id="pod33"></a>$] </dt> <dd> <p>See <a href="#%24%5EV">"$^V"</a> for a more modern representation of the Perl version that allows accurate string comparisons.</p> <p>The version + patchlevel / 1000 of the Perl interpreter. This variable can be used to determine whether the Perl interpreter executing a script is in the right range of versions:</p> <pre><code>warn "No checksumming!\n" if $] < 3.019;</code></pre> <p>The floating point representation can sometimes lead to inaccurate numeric comparisons.</p> <p>See also the documentation of <code>use VERSION</code> and <code>require VERSION</code> for a convenient way to fail if the running Perl interpreter is too old.</p> <p>Mnemonic: Is this version of perl in the right bracket?</p> </dd> </dl> </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>