CINXE.COM

B - The Perl Compiler Backend - 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>B - The Perl Compiler Backend - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/B"> <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="/"><img src="/images/perl_camel_30.png" width="30" height="30" class="d-inline-block align-top" alt="Perl Camel Logo"> 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.4</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/B">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1/B">5.40.1</a> <a class="dropdown-item" href="/5.40.0/B">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3/B">5.38.3</a> <a class="dropdown-item" href="/5.38.2/B">5.38.2</a> <a class="dropdown-item" href="/5.38.1/B">5.38.1</a> <a class="dropdown-item" href="/5.38.0/B">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/B">5.36.3</a> <a class="dropdown-item" href="/5.36.2/B">5.36.2</a> <a class="dropdown-item" href="/5.36.1/B">5.36.1</a> <a class="dropdown-item" href="/5.36.0/B">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/B">5.34.3</a> <a class="dropdown-item" href="/5.34.2/B">5.34.2</a> <a class="dropdown-item" href="/5.34.1/B">5.34.1</a> <a class="dropdown-item" href="/5.34.0/B">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/B">5.32.1</a> <a class="dropdown-item" href="/5.32.0/B">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/B">5.30.3</a> <a class="dropdown-item" href="/5.30.2/B">5.30.2</a> <a class="dropdown-item" href="/5.30.1/B">5.30.1</a> <a class="dropdown-item" href="/5.30.0/B">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/B">5.28.3</a> <a class="dropdown-item" href="/5.28.2/B">5.28.2</a> <a class="dropdown-item" href="/5.28.1/B">5.28.1</a> <a class="dropdown-item" href="/5.28.0/B">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/B">5.26.3</a> <a class="dropdown-item" href="/5.26.2/B">5.26.2</a> <a class="dropdown-item" href="/5.26.1/B">5.26.1</a> <a class="dropdown-item" href="/5.26.0/B">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/B">5.24.4</a> <a class="dropdown-item" href="/5.24.3/B">5.24.3</a> <a class="dropdown-item" href="/5.24.2/B">5.24.2</a> <a class="dropdown-item" href="/5.24.1/B">5.24.1</a> <a class="dropdown-item" href="/5.24.0/B">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/B">5.22.4</a> <a class="dropdown-item" href="/5.22.3/B">5.22.3</a> <a class="dropdown-item" href="/5.22.2/B">5.22.2</a> <a class="dropdown-item" href="/5.22.1/B">5.22.1</a> <a class="dropdown-item" href="/5.22.0/B">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/B">5.20.3</a> <a class="dropdown-item" href="/5.20.2/B">5.20.2</a> <a class="dropdown-item" href="/5.20.1/B">5.20.1</a> <a class="dropdown-item" href="/5.20.0/B">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item active" href="/5.18.4/B">5.18.4</a> <a class="dropdown-item" href="/5.18.3/B">5.18.3</a> <a class="dropdown-item" href="/5.18.2/B">5.18.2</a> <a class="dropdown-item" href="/5.18.1/B">5.18.1</a> <a class="dropdown-item" href="/5.18.0/B">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/B">5.16.3</a> <a class="dropdown-item" href="/5.16.2/B">5.16.2</a> <a class="dropdown-item" href="/5.16.1/B">5.16.1</a> <a class="dropdown-item" href="/5.16.0/B">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/B">5.14.4</a> <a class="dropdown-item" href="/5.14.3/B">5.14.3</a> <a class="dropdown-item" href="/5.14.2/B">5.14.2</a> <a class="dropdown-item" href="/5.14.1/B">5.14.1</a> <a class="dropdown-item" href="/5.14.0/B">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/B">5.12.5</a> <a class="dropdown-item" href="/5.12.4/B">5.12.4</a> <a class="dropdown-item" href="/5.12.3/B">5.12.3</a> <a class="dropdown-item" href="/5.12.2/B">5.12.2</a> <a class="dropdown-item" href="/5.12.1/B">5.12.1</a> <a class="dropdown-item" href="/5.12.0/B">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/B">5.10.1</a> <a class="dropdown-item" href="/5.10.0/B">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/B">5.8.9</a> <a class="dropdown-item" href="/5.8.8/B">5.8.8</a> <a class="dropdown-item" href="/5.8.7/B">5.8.7</a> <a class="dropdown-item" href="/5.8.6/B">5.8.6</a> <a class="dropdown-item" href="/5.8.5/B">5.8.5</a> <a class="dropdown-item" href="/5.8.4/B">5.8.4</a> <a class="dropdown-item" href="/5.8.3/B">5.8.3</a> <a class="dropdown-item" href="/5.8.2/B">5.8.2</a> <a class="dropdown-item" href="/5.8.1/B">5.8.1</a> <a class="dropdown-item" href="/5.8.0/B">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/B">5.6.2</a> <a class="dropdown-item" href="/5.6.1/B">5.6.1</a> <a class="dropdown-item" href="/5.6.0/B">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/B">5.005_04</a> <a class="dropdown-item" href="/5.005_03/B">5.005_03</a> <a class="dropdown-item" href="/5.005_02/B">5.005_02</a> <a class="dropdown-item" href="/5.005_01/B">5.005_01</a> <a class="dropdown-item" href="/5.005/B">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/B">blead</a> <a class="dropdown-item" href="/5.41.9/B">5.41.9</a> <a class="dropdown-item" href="/5.41.8/B">5.41.8</a> <a class="dropdown-item" href="/5.41.7/B">5.41.7</a> <a class="dropdown-item" href="/5.41.6/B">5.41.6</a> <a class="dropdown-item" href="/5.41.5/B">5.41.5</a> <a class="dropdown-item" href="/5.41.4/B">5.41.4</a> <a class="dropdown-item" href="/5.41.3/B">5.41.3</a> <a class="dropdown-item" href="/5.41.2/B">5.41.2</a> <a class="dropdown-item" href="/5.41.1/B">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1-RC1/B">5.40.1-RC1</a> <a class="dropdown-item" href="/5.40.0-RC2/B">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/B">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/B">5.39.10</a> <a class="dropdown-item" href="/5.39.9/B">5.39.9</a> <a class="dropdown-item" href="/5.39.8/B">5.39.8</a> <a class="dropdown-item" href="/5.39.7/B">5.39.7</a> <a class="dropdown-item" href="/5.39.6/B">5.39.6</a> <a class="dropdown-item" href="/5.39.5/B">5.39.5</a> <a class="dropdown-item" href="/5.39.4/B">5.39.4</a> <a class="dropdown-item" href="/5.39.3/B">5.39.3</a> <a class="dropdown-item" href="/5.39.2/B">5.39.2</a> <a class="dropdown-item" href="/5.39.1/B">5.39.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3-RC1/B">5.38.3-RC1</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.4/perl">Perl</a> <a class="dropdown-item" href="/5.18.4/perlintro">Intro</a> <a class="dropdown-item" href="/5.18.4/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.18.4/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.18.4/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/perlop">Operators</a> <a class="dropdown-item" href="/5.18.4/functions">Functions</a> <a class="dropdown-item" href="/5.18.4/variables">Variables</a> <a class="dropdown-item" href="/5.18.4/modules">Modules</a> <a class="dropdown-item" href="/5.18.4/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.18.4/perlcommunity">Community</a> <a class="dropdown-item" href="/5.18.4/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.4/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.4/B">B</a> <div id="more"> (<a href="/5.18.4/B.txt">source</a>, <a href="https://metacpan.org/pod/B">CPAN</a>) </div> <div id="moduleversion">version 1.42_02</div> </div> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.18.4. <a href="/B">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="#SYNOPSIS">SYNOPSIS</a> </li> <li> <a class="text-decoration-none" href="#DESCRIPTION">DESCRIPTION</a> </li> <li> <a class="text-decoration-none" href="#OVERVIEW">OVERVIEW</a> </li> <li> <a class="text-decoration-none" href="#Utility-Functions">Utility Functions</a> <ul> <li> <a class="text-decoration-none" href="#Functions-Returning-B::SV,-B::AV,-B::HV,-and-B::CV-objects">Functions Returning B::SV, B::AV, B::HV, and B::CV objects</a> </li> <li> <a class="text-decoration-none" href="#Functions-for-Examining-the-Symbol-Table">Functions for Examining the Symbol Table</a> </li> <li> <a class="text-decoration-none" href="#Functions-Returning-B::OP-objects-or-for-walking-op-trees">Functions Returning B::OP objects or for walking op trees</a> </li> <li> <a class="text-decoration-none" href="#Miscellaneous-Utility-Functions">Miscellaneous Utility Functions</a> </li> <li> <a class="text-decoration-none" href="#Exported-utility-variables">Exported utility variables</a> </li> </ul> </li> <li> <a class="text-decoration-none" href="#OVERVIEW-OF-CLASSES">OVERVIEW OF CLASSES</a> <ul> <li> <a class="text-decoration-none" href="#SV-RELATED-CLASSES">SV-RELATED CLASSES</a> </li> <li> <a class="text-decoration-none" href="#B::SV-Methods">B::SV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::IV-Methods">B::IV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::NV-Methods">B::NV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::RV-Methods">B::RV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::PV-Methods">B::PV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::PVMG-Methods">B::PVMG Methods</a> </li> <li> <a class="text-decoration-none" href="#B::MAGIC-Methods">B::MAGIC Methods</a> </li> <li> <a class="text-decoration-none" href="#B::PVLV-Methods">B::PVLV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::BM-Methods">B::BM Methods</a> </li> <li> <a class="text-decoration-none" href="#B::GV-Methods">B::GV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::IO-Methods">B::IO Methods</a> </li> <li> <a class="text-decoration-none" href="#B::AV-Methods">B::AV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::CV-Methods">B::CV Methods</a> </li> <li> <a class="text-decoration-none" href="#B::HV-Methods">B::HV Methods</a> </li> <li> <a class="text-decoration-none" href="#OP-RELATED-CLASSES">OP-RELATED CLASSES</a> </li> <li> <a class="text-decoration-none" href="#B::OP-Methods">B::OP Methods</a> </li> <li> <a class="text-decoration-none" href="#B::UNOP-METHOD">B::UNOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::BINOP-METHOD">B::BINOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::LOGOP-METHOD">B::LOGOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::LISTOP-METHOD">B::LISTOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::PMOP-Methods">B::PMOP Methods</a> </li> <li> <a class="text-decoration-none" href="#B::SVOP-METHOD">B::SVOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::PADOP-METHOD">B::PADOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::PVOP-METHOD">B::PVOP METHOD</a> </li> <li> <a class="text-decoration-none" href="#B::LOOP-Methods">B::LOOP Methods</a> </li> <li> <a class="text-decoration-none" href="#B::COP-Methods">B::COP Methods</a> </li> <li> <a class="text-decoration-none" href="#$B::overlay">$B::overlay</a> </li> </ul> </li> <li> <a class="text-decoration-none" href="#AUTHOR">AUTHOR</a> </li> </ul> <h1 id="NAME"><a class="permalink" href="#NAME">#</a>NAME</h1> <p>B - The Perl Compiler Backend</p> <h1 id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">#</a>SYNOPSIS</h1> <pre><code>use B;</code></pre> <h1 id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">#</a>DESCRIPTION</h1> <p>The <code>B</code> module supplies classes which allow a Perl program to delve into its own innards. It is the module used to implement the &quot;backends&quot; of the Perl compiler. Usage of the compiler does not require knowledge of this module: see the <i>O</i> module for the user-visible part. The <code>B</code> module is of use to those who want to write new compiler backends. This documentation assumes that the reader knows a fair amount about perl&#39;s internals including such things as SVs, OPs and the internal symbol table and syntax tree of a program.</p> <h1 id="OVERVIEW"><a class="permalink" href="#OVERVIEW">#</a>OVERVIEW</h1> <p>The <code>B</code> module contains a set of utility functions for querying the current state of the Perl interpreter; typically these functions return objects from the B::SV and B::OP classes, or their derived classes. These classes in turn define methods for querying the resulting objects about their own internal state.</p> <h1 id="Utility-Functions"><a class="permalink" href="#Utility-Functions">#</a><a id="Utility"></a>Utility Functions</h1> <p>The <code>B</code> module exports a variety of functions: some are simple utility functions, others provide a Perl program with a way to get an initial &quot;handle&quot; on an internal object.</p> <h2 id="Functions-Returning-B::SV,-B::AV,-B::HV,-and-B::CV-objects"><a class="permalink" href="#Functions-Returning-B::SV,-B::AV,-B::HV,-and-B::CV-objects">#</a><a id="Functions"></a><a id="Functions-Returning-B::SV-B::AV-B::HV-and-B::CV-objects"></a>Functions Returning <code>B::SV</code>, <code>B::AV</code>, <code>B::HV</code>, and <code>B::CV</code> objects</h2> <p>For descriptions of the class hierarchy of these objects and the methods that can be called on them, see below, <a href="#OVERVIEW-OF-CLASSES">&quot;OVERVIEW OF CLASSES&quot;</a> and <a href="#SV-RELATED-CLASSES">&quot;SV-RELATED CLASSES&quot;</a>.</p> <dl> <dt id="sv_undef"><a class="permalink" href="#sv_undef">#</a>sv_undef</dt> <dd> <p>Returns the SV object corresponding to the C variable <code>sv_undef</code>.</p> </dd> <dt id="sv_yes"><a class="permalink" href="#sv_yes">#</a>sv_yes</dt> <dd> <p>Returns the SV object corresponding to the C variable <code>sv_yes</code>.</p> </dd> <dt id="sv_no"><a class="permalink" href="#sv_no">#</a>sv_no</dt> <dd> <p>Returns the SV object corresponding to the C variable <code>sv_no</code>.</p> </dd> <dt id="svref_2object(SVREF)"><a class="permalink" href="#svref_2object(SVREF)">#</a><a id="svref_2object"></a><a id="svref_2object-SVREF"></a>svref_2object(SVREF)</dt> <dd> <p>Takes a reference to any Perl value, and turns the referred-to value into an object in the appropriate B::OP-derived or B::SV-derived class. Apart from functions such as <code>main_root</code>, this is the primary way to get an initial &quot;handle&quot; on an internal perl data structure which can then be followed with the other access methods.</p> <p>The returned object will only be valid as long as the underlying OPs and SVs continue to exist. Do not attempt to use the object after the underlying structures are freed.</p> </dd> <dt id="amagic_generation"><a class="permalink" href="#amagic_generation">#</a>amagic_generation</dt> <dd> <p>Returns the SV object corresponding to the C variable <code>amagic_generation</code>. As of Perl 5.18, this is just an alias to <code>PL_na</code>, so its value is meaningless.</p> </dd> <dt id="init_av"><a class="permalink" href="#init_av">#</a>init_av</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) representing INIT blocks.</p> </dd> <dt id="check_av"><a class="permalink" href="#check_av">#</a>check_av</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) representing CHECK blocks.</p> </dd> <dt id="unitcheck_av"><a class="permalink" href="#unitcheck_av">#</a>unitcheck_av</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) representing UNITCHECK blocks.</p> </dd> <dt id="begin_av"><a class="permalink" href="#begin_av">#</a>begin_av</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) representing BEGIN blocks.</p> </dd> <dt id="end_av"><a class="permalink" href="#end_av">#</a>end_av</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) representing END blocks.</p> </dd> <dt id="comppadlist"><a class="permalink" href="#comppadlist">#</a>comppadlist</dt> <dd> <p>Returns the AV object (i.e. in class B::AV) of the global comppadlist.</p> </dd> <dt id="regex_padav"><a class="permalink" href="#regex_padav">#</a>regex_padav</dt> <dd> <p>Only when perl was compiled with ithreads.</p> </dd> <dt id="main_cv"><a class="permalink" href="#main_cv">#</a>main_cv</dt> <dd> <p>Return the (faked) CV corresponding to the main part of the Perl program.</p> </dd> </dl> <h2 id="Functions-for-Examining-the-Symbol-Table"><a class="permalink" href="#Functions-for-Examining-the-Symbol-Table">#</a><a id="Functions1"></a>Functions for Examining the Symbol Table</h2> <dl> <dt id="walksymtable(SYMREF,-METHOD,-RECURSE,-PREFIX)"><a class="permalink" href="#walksymtable(SYMREF,-METHOD,-RECURSE,-PREFIX)">#</a><a id="walksymtable"></a><a id="walksymtable-SYMREF-METHOD-RECURSE-PREFIX"></a>walksymtable(SYMREF, METHOD, RECURSE, PREFIX)</dt> <dd> <p>Walk the symbol table starting at SYMREF and call METHOD on each symbol (a B::GV object) visited. When the walk reaches package symbols (such as &quot;Foo::&quot;) it invokes RECURSE, passing in the symbol name, and only recurses into the package if that sub returns true.</p> <p>PREFIX is the name of the SYMREF you&#39;re walking.</p> <p>For example:</p> <pre><code># Walk CGI&#39;s symbol table calling print_subs on each symbol. # Recurse only into CGI::Util:: walksymtable(\%CGI::, &#39;print_subs&#39;, sub { $_[0] eq &#39;CGI::Util::&#39; }, &#39;CGI::&#39;);</code></pre> <p>print_subs() is a B::GV method you have declared. Also see <a href="#B%3A%3AGV-Methods">&quot;B::GV Methods&quot;</a>, below.</p> </dd> </dl> <h2 id="Functions-Returning-B::OP-objects-or-for-walking-op-trees"><a class="permalink" href="#Functions-Returning-B::OP-objects-or-for-walking-op-trees">#</a><a id="Functions2"></a>Functions Returning <code>B::OP</code> objects or for walking op trees</h2> <p>For descriptions of the class hierarchy of these objects and the methods that can be called on them, see below, <a href="#OVERVIEW-OF-CLASSES">&quot;OVERVIEW OF CLASSES&quot;</a> and <a href="#OP-RELATED-CLASSES">&quot;OP-RELATED CLASSES&quot;</a>.</p> <dl> <dt id="main_root"><a class="permalink" href="#main_root">#</a>main_root</dt> <dd> <p>Returns the root op (i.e. an object in the appropriate B::OP-derived class) of the main part of the Perl program.</p> </dd> <dt id="main_start"><a class="permalink" href="#main_start">#</a>main_start</dt> <dd> <p>Returns the starting op of the main part of the Perl program.</p> </dd> <dt id="walkoptree(OP,-METHOD)"><a class="permalink" href="#walkoptree(OP,-METHOD)">#</a><a id="walkoptree"></a><a id="walkoptree-OP-METHOD"></a>walkoptree(OP, METHOD)</dt> <dd> <p>Does a tree-walk of the syntax tree based at OP and calls METHOD on each op it visits. Each node is visited before its children. If <code>walkoptree_debug</code> (see below) has been called to turn debugging on then the method <code>walkoptree_debug</code> is called on each op before METHOD is called.</p> </dd> <dt id="walkoptree_debug(DEBUG)"><a class="permalink" href="#walkoptree_debug(DEBUG)">#</a><a id="walkoptree_debug"></a><a id="walkoptree_debug-DEBUG"></a>walkoptree_debug(DEBUG)</dt> <dd> <p>Returns the current debugging flag for <code>walkoptree</code>. If the optional DEBUG argument is non-zero, it sets the debugging flag to that. See the description of <code>walkoptree</code> above for what the debugging flag does.</p> </dd> </dl> <h2 id="Miscellaneous-Utility-Functions"><a class="permalink" href="#Miscellaneous-Utility-Functions">#</a><a id="Miscellaneous"></a>Miscellaneous Utility Functions</h2> <dl> <dt id="ppname(OPNUM)"><a class="permalink" href="#ppname(OPNUM)">#</a><a id="ppname"></a><a id="ppname-OPNUM"></a>ppname(OPNUM)</dt> <dd> <p>Return the PP function name (e.g. &quot;pp_add&quot;) of op number OPNUM.</p> </dd> <dt id="hash(STR)"><a class="permalink" href="#hash(STR)">#</a><a id="hash"></a><a id="hash-STR"></a>hash(STR)</dt> <dd> <p>Returns a string in the form &quot;0x...&quot; representing the value of the internal hash function used by perl on string STR.</p> </dd> <dt id="cast_I32(I)"><a class="permalink" href="#cast_I32(I)">#</a><a id="cast_I32"></a><a id="cast_I32-I"></a>cast_I32(I)</dt> <dd> <p>Casts I to the internal I32 type used by that perl.</p> </dd> <dt id="minus_c"><a class="permalink" href="#minus_c">#</a>minus_c</dt> <dd> <p>Does the equivalent of the <code>-c</code> command-line option. Obviously, this is only useful in a BEGIN block or else the flag is set too late.</p> </dd> <dt id="cstring(STR)"><a class="permalink" href="#cstring(STR)">#</a><a id="cstring"></a><a id="cstring-STR"></a>cstring(STR)</dt> <dd> <p>Returns a double-quote-surrounded escaped version of STR which can be used as a string in C source code.</p> </dd> <dt id="perlstring(STR)"><a class="permalink" href="#perlstring(STR)">#</a><a id="perlstring"></a><a id="perlstring-STR"></a>perlstring(STR)</dt> <dd> <p>Returns a double-quote-surrounded escaped version of STR which can be used as a string in Perl source code.</p> </dd> <dt id="class(OBJ)"><a class="permalink" href="#class(OBJ)">#</a><a id="class"></a><a id="class-OBJ"></a>class(OBJ)</dt> <dd> <p>Returns the class of an object without the part of the classname preceding the first <code>&quot;::&quot;</code>. This is used to turn <code>&quot;B::UNOP&quot;</code> into <code>&quot;UNOP&quot;</code> for example.</p> </dd> <dt id="threadsv_names"><a class="permalink" href="#threadsv_names">#</a>threadsv_names</dt> <dd> <p>In a perl compiled for threads, this returns a list of the special per-thread threadsv variables.</p> </dd> </dl> <h2 id="Exported-utility-variables"><a class="permalink" href="#Exported-utility-variables">#</a><a id="Exported"></a>Exported utility variables</h2> <dl> <dt id="@optype"><a class="permalink" href="#@optype">#</a><a id="optype"></a>@optype</dt> <dd> <pre><code>my $op_type = $optype[$op_type_num];</code></pre> <p>A simple mapping of the op type number to its type (like &#39;COP&#39; or &#39;BINOP&#39;).</p> </dd> <dt id="@specialsv_name"><a class="permalink" href="#@specialsv_name">#</a><a id="specialsv_name"></a>@specialsv_name</dt> <dd> <pre><code>my $sv_name = $specialsv_name[$sv_index];</code></pre> <p>Certain SV types are considered &#39;special&#39;. They&#39;re represented by B::SPECIAL and are referred to by a number from the specialsv_list. This array maps that number back to the name of the SV (like &#39;Nullsv&#39; or &#39;&amp;PL_sv_undef&#39;).</p> </dd> </dl> <h1 id="OVERVIEW-OF-CLASSES"><a class="permalink" href="#OVERVIEW-OF-CLASSES">#</a><a id="OVERVIEW1"></a>OVERVIEW OF CLASSES</h1> <p>The C structures used by Perl&#39;s internals to hold SV and OP information (PVIV, AV, HV, ..., OP, SVOP, UNOP, ...) are modelled on a class hierarchy and the <code>B</code> module gives access to them via a true object hierarchy. Structure fields which point to other objects (whether types of SV or types of OP) are represented by the <code>B</code> module as Perl objects of the appropriate class.</p> <p>The bulk of the <code>B</code> module is the methods for accessing fields of these structures.</p> <p>Note that all access is read-only. You cannot modify the internals by using this module. Also, note that the B::OP and B::SV objects created by this module are only valid for as long as the underlying objects exist; their creation doesn&#39;t increase the reference counts of the underlying objects. Trying to access the fields of a freed object will give incomprehensible results, or worse.</p> <h2 id="SV-RELATED-CLASSES"><a class="permalink" href="#SV-RELATED-CLASSES">#</a><a id="SV1"></a>SV-RELATED CLASSES</h2> <p>B::IV, B::NV, B::RV, B::PV, B::PVIV, B::PVNV, B::PVMG, B::BM (5.9.5 and earlier), B::PVLV, B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes correspond in the obvious way to the underlying C structures of similar names. The inheritance hierarchy mimics the underlying C &quot;inheritance&quot;. For the 5.10.x branch, (<i>ie</i> 5.10.0, 5.10.1 <i>etc</i>) this is:</p> <pre><code class="plaintext"> B::SV | +------------+------------+------------+ | | | | B::PV B::IV B::NV B::RV \ / / \ / / B::PVIV / \ / \ / \ / B::PVNV | | B::PVMG | +-----+-----+-----+-----+ | | | | | B::AV B::GV B::HV B::CV B::IO | | | | B::PVLV B::FM</code></pre> <p>For 5.9.0 and earlier, PVLV is a direct subclass of PVMG, and BM is still present as a distinct type, so the base of this diagram is</p> <pre><code class="plaintext"> | | B::PVMG | +------+-----+-----+-----+-----+-----+ | | | | | | | B::PVLV B::BM B::AV B::GV B::HV B::CV B::IO | | B::FM</code></pre> <p>For 5.11.0 and later, B::RV is abolished, and IVs can be used to store references, and a new type B::REGEXP is introduced, giving this structure:</p> <pre><code class="plaintext"> B::SV | +------------+------------+ | | | B::PV B::IV B::NV \ / / \ / / B::PVIV / \ / \ / \ / B::PVNV | | B::PVMG | +-------+-------+---+---+-------+-------+ | | | | | | B::AV B::GV B::HV B::CV B::IO B::REGEXP | | | | B::PVLV B::FM</code></pre> <p>Access methods correspond to the underlying C macros for field access, usually with the leading &quot;class indication&quot; prefix removed (Sv, Av, Hv, ...). The leading prefix is only left in cases where its removal would cause a clash in method name. For example, <code>GvREFCNT</code> stays as-is since its abbreviation would clash with the &quot;superclass&quot; method <code>REFCNT</code> (corresponding to the C function <code>SvREFCNT</code>).</p> <h2 id="B::SV-Methods"><a class="permalink" href="#B::SV-Methods">#</a><a id="B"></a>B::SV Methods</h2> <dl> <dt id="REFCNT"><a class="permalink" href="#REFCNT">#</a>REFCNT</dt> <dd> </dd> <dt id="FLAGS"><a class="permalink" href="#FLAGS">#</a>FLAGS</dt> <dd> </dd> <dt id="object_2svref"><a class="permalink" href="#object_2svref">#</a>object_2svref</dt> <dd> <p>Returns a reference to the regular scalar corresponding to this B::SV object. In other words, this method is the inverse operation to the svref_2object() subroutine. This scalar and other data it points at should be considered read-only: modifying them is neither safe nor guaranteed to have a sensible effect.</p> </dd> </dl> <h2 id="B::IV-Methods"><a class="permalink" href="#B::IV-Methods">#</a><a id="B1"></a>B::IV Methods</h2> <dl> <dt id="IV"><a class="permalink" href="#IV">#</a>IV</dt> <dd> <p>Returns the value of the IV, <i>interpreted as a signed integer</i>. This will be misleading if <code>FLAGS &amp; SVf_IVisUV</code>. Perhaps you want the <code>int_value</code> method instead?</p> </dd> <dt id="IVX"><a class="permalink" href="#IVX">#</a>IVX</dt> <dd> </dd> <dt id="UVX"><a class="permalink" href="#UVX">#</a>UVX</dt> <dd> </dd> <dt id="int_value"><a class="permalink" href="#int_value">#</a>int_value</dt> <dd> <p>This method returns the value of the IV as an integer. It differs from <code>IV</code> in that it returns the correct value regardless of whether it&#39;s stored signed or unsigned.</p> </dd> <dt id="needs64bits"><a class="permalink" href="#needs64bits">#</a>needs64bits</dt> <dd> </dd> <dt id="packiv"><a class="permalink" href="#packiv">#</a>packiv</dt> <dd> </dd> </dl> <h2 id="B::NV-Methods"><a class="permalink" href="#B::NV-Methods">#</a><a id="B2"></a>B::NV Methods</h2> <dl> <dt id="NV"><a class="permalink" href="#NV">#</a>NV</dt> <dd> </dd> <dt id="NVX"><a class="permalink" href="#NVX">#</a>NVX</dt> <dd> </dd> </dl> <h2 id="B::RV-Methods"><a class="permalink" href="#B::RV-Methods">#</a><a id="B3"></a>B::RV Methods</h2> <dl> <dt id="RV"><a class="permalink" href="#RV">#</a>RV</dt> <dd> </dd> </dl> <h2 id="B::PV-Methods"><a class="permalink" href="#B::PV-Methods">#</a><a id="B4"></a>B::PV Methods</h2> <dl> <dt id="PV"><a class="permalink" href="#PV">#</a>PV</dt> <dd> <p>This method is the one you usually want. It constructs a string using the length and offset information in the struct: for ordinary scalars it will return the string that you&#39;d see from Perl, even if it contains null characters.</p> </dd> <dt id="RV1"><a class="permalink" href="#RV1">#</a>RV</dt> <dd> <p>Same as B::RV::RV, except that it will die() if the PV isn&#39;t a reference.</p> </dd> <dt id="PVX"><a class="permalink" href="#PVX">#</a>PVX</dt> <dd> <p>This method is less often useful. It assumes that the string stored in the struct is null-terminated, and disregards the length information.</p> <p>It is the appropriate method to use if you need to get the name of a lexical variable from a padname array. Lexical variable names are always stored with a null terminator, and the length field (CUR) is overloaded for other purposes and can&#39;t be relied on here.</p> </dd> <dt id="CUR"><a class="permalink" href="#CUR">#</a>CUR</dt> <dd> <p>This method returns the internal length field, which consists of the number of internal bytes, not necessarily the number of logical characters.</p> </dd> <dt id="LEN"><a class="permalink" href="#LEN">#</a>LEN</dt> <dd> <p>This method returns the number of bytes allocated (via malloc) for storing the string. This is 0 if the scalar does not &quot;own&quot; the string.</p> </dd> </dl> <h2 id="B::PVMG-Methods"><a class="permalink" href="#B::PVMG-Methods">#</a><a id="B5"></a>B::PVMG Methods</h2> <dl> <dt id="MAGIC"><a class="permalink" href="#MAGIC">#</a>MAGIC</dt> <dd> </dd> <dt id="SvSTASH"><a class="permalink" href="#SvSTASH">#</a>SvSTASH</dt> <dd> </dd> </dl> <h2 id="B::MAGIC-Methods"><a class="permalink" href="#B::MAGIC-Methods">#</a><a id="B6"></a>B::MAGIC Methods</h2> <dl> <dt id="MOREMAGIC"><a class="permalink" href="#MOREMAGIC">#</a>MOREMAGIC</dt> <dd> </dd> <dt id="precomp"><a class="permalink" href="#precomp">#</a>precomp</dt> <dd> <p>Only valid on r-magic, returns the string that generated the regexp.</p> </dd> <dt id="PRIVATE"><a class="permalink" href="#PRIVATE">#</a>PRIVATE</dt> <dd> </dd> <dt id="TYPE"><a class="permalink" href="#TYPE">#</a>TYPE</dt> <dd> </dd> <dt id="FLAGS1"><a class="permalink" href="#FLAGS1">#</a>FLAGS</dt> <dd> </dd> <dt id="OBJ"><a class="permalink" href="#OBJ">#</a>OBJ</dt> <dd> <p>Will die() if called on r-magic.</p> </dd> <dt id="PTR"><a class="permalink" href="#PTR">#</a>PTR</dt> <dd> </dd> <dt id="REGEX"><a class="permalink" href="#REGEX">#</a>REGEX</dt> <dd> <p>Only valid on r-magic, returns the integer value of the REGEX stored in the MAGIC.</p> </dd> </dl> <h2 id="B::PVLV-Methods"><a class="permalink" href="#B::PVLV-Methods">#</a><a id="B7"></a>B::PVLV Methods</h2> <dl> <dt id="TARGOFF"><a class="permalink" href="#TARGOFF">#</a>TARGOFF</dt> <dd> </dd> <dt id="TARGLEN"><a class="permalink" href="#TARGLEN">#</a>TARGLEN</dt> <dd> </dd> <dt id="TYPE1"><a class="permalink" href="#TYPE1">#</a>TYPE</dt> <dd> </dd> <dt id="TARG"><a class="permalink" href="#TARG">#</a>TARG</dt> <dd> </dd> </dl> <h2 id="B::BM-Methods"><a class="permalink" href="#B::BM-Methods">#</a><a id="B8"></a>B::BM Methods</h2> <dl> <dt id="USEFUL"><a class="permalink" href="#USEFUL">#</a>USEFUL</dt> <dd> </dd> <dt id="PREVIOUS"><a class="permalink" href="#PREVIOUS">#</a>PREVIOUS</dt> <dd> </dd> <dt id="RARE"><a class="permalink" href="#RARE">#</a>RARE</dt> <dd> </dd> <dt id="TABLE"><a class="permalink" href="#TABLE">#</a>TABLE</dt> <dd> </dd> </dl> <h2 id="B::GV-Methods"><a class="permalink" href="#B::GV-Methods">#</a><a id="B9"></a>B::GV Methods</h2> <dl> <dt id="is_empty"><a class="permalink" href="#is_empty">#</a>is_empty</dt> <dd> <p>This method returns TRUE if the GP field of the GV is NULL.</p> </dd> <dt id="NAME1"><a class="permalink" href="#NAME1">#</a>NAME</dt> <dd> </dd> <dt id="SAFENAME"><a class="permalink" href="#SAFENAME">#</a>SAFENAME</dt> <dd> <p>This method returns the name of the glob, but if the first character of the name is a control character, then it converts it to ^X first, so that *^G would return &quot;^G&quot; rather than &quot;\cG&quot;.</p> <p>It&#39;s useful if you want to print out the name of a variable. If you restrict yourself to globs which exist at compile-time then the result ought to be unambiguous, because code like <code>${&quot;^G&quot;} = 1</code> is compiled as two ops - a constant string and a dereference (rv2gv) - so that the glob is created at runtime.</p> <p>If you&#39;re working with globs at runtime, and need to disambiguate *^G from *{&quot;^G&quot;}, then you should use the raw NAME method.</p> </dd> <dt id="STASH"><a class="permalink" href="#STASH">#</a>STASH</dt> <dd> </dd> <dt id="SV"><a class="permalink" href="#SV">#</a>SV</dt> <dd> </dd> <dt id="IO"><a class="permalink" href="#IO">#</a>IO</dt> <dd> </dd> <dt id="FORM"><a class="permalink" href="#FORM">#</a>FORM</dt> <dd> </dd> <dt id="AV"><a class="permalink" href="#AV">#</a>AV</dt> <dd> </dd> <dt id="HV"><a class="permalink" href="#HV">#</a>HV</dt> <dd> </dd> <dt id="EGV"><a class="permalink" href="#EGV">#</a>EGV</dt> <dd> </dd> <dt id="CV"><a class="permalink" href="#CV">#</a>CV</dt> <dd> </dd> <dt id="CVGEN"><a class="permalink" href="#CVGEN">#</a>CVGEN</dt> <dd> </dd> <dt id="LINE"><a class="permalink" href="#LINE">#</a>LINE</dt> <dd> </dd> <dt id="FILE"><a class="permalink" href="#FILE">#</a>FILE</dt> <dd> </dd> <dt id="FILEGV"><a class="permalink" href="#FILEGV">#</a>FILEGV</dt> <dd> </dd> <dt id="GvREFCNT"><a class="permalink" href="#GvREFCNT">#</a>GvREFCNT</dt> <dd> </dd> <dt id="FLAGS2"><a class="permalink" href="#FLAGS2">#</a>FLAGS</dt> <dd> </dd> </dl> <h2 id="B::IO-Methods"><a class="permalink" href="#B::IO-Methods">#</a><a id="B10"></a>B::IO Methods</h2> <p>B::IO objects derive from IO objects and you will get more information from the IO object itself.</p> <p>For example:</p> <pre><code>$gvio = B::svref_2object(\*main::stdin)-&gt;IO; $IO = $gvio-&gt;object_2svref(); $fd = $IO-&gt;fileno();</code></pre> <dl> <dt id="LINES"><a class="permalink" href="#LINES">#</a>LINES</dt> <dd> </dd> <dt id="PAGE"><a class="permalink" href="#PAGE">#</a>PAGE</dt> <dd> </dd> <dt id="PAGE_LEN"><a class="permalink" href="#PAGE_LEN">#</a>PAGE_LEN</dt> <dd> </dd> <dt id="LINES_LEFT"><a class="permalink" href="#LINES_LEFT">#</a>LINES_LEFT</dt> <dd> </dd> <dt id="TOP_NAME"><a class="permalink" href="#TOP_NAME">#</a>TOP_NAME</dt> <dd> </dd> <dt id="TOP_GV"><a class="permalink" href="#TOP_GV">#</a>TOP_GV</dt> <dd> </dd> <dt id="FMT_NAME"><a class="permalink" href="#FMT_NAME">#</a>FMT_NAME</dt> <dd> </dd> <dt id="FMT_GV"><a class="permalink" href="#FMT_GV">#</a>FMT_GV</dt> <dd> </dd> <dt id="BOTTOM_NAME"><a class="permalink" href="#BOTTOM_NAME">#</a>BOTTOM_NAME</dt> <dd> </dd> <dt id="BOTTOM_GV"><a class="permalink" href="#BOTTOM_GV">#</a>BOTTOM_GV</dt> <dd> </dd> <dt id="SUBPROCESS"><a class="permalink" href="#SUBPROCESS">#</a>SUBPROCESS</dt> <dd> </dd> <dt id="IoTYPE"><a class="permalink" href="#IoTYPE">#</a>IoTYPE</dt> <dd> <p>A character symbolizing the type of IO Handle.</p> <pre><code class="plaintext">- STDIN/OUT I STDIN/OUT/ERR &lt; read-only &gt; write-only a append + read and write s socket | pipe I IMPLICIT # NUMERIC space closed handle \0 closed internal handle</code></pre> </dd> <dt id="IoFLAGS"><a class="permalink" href="#IoFLAGS">#</a>IoFLAGS</dt> <dd> </dd> <dt id="IsSTD"><a class="permalink" href="#IsSTD">#</a>IsSTD</dt> <dd> <p>Takes one argument ( &#39;stdin&#39; | &#39;stdout&#39; | &#39;stderr&#39; ) and returns true if the IoIFP of the object is equal to the handle whose name was passed as argument; i.e., $io-&gt;IsSTD(&#39;stderr&#39;) is true if IoIFP($io) == PerlIO_stderr().</p> </dd> </dl> <h2 id="B::AV-Methods"><a class="permalink" href="#B::AV-Methods">#</a><a id="B11"></a>B::AV Methods</h2> <dl> <dt id="FILL"><a class="permalink" href="#FILL">#</a>FILL</dt> <dd> </dd> <dt id="MAX"><a class="permalink" href="#MAX">#</a>MAX</dt> <dd> </dd> <dt id="ARRAY"><a class="permalink" href="#ARRAY">#</a>ARRAY</dt> <dd> </dd> <dt id="ARRAYelt"><a class="permalink" href="#ARRAYelt">#</a>ARRAYelt</dt> <dd> <p>Like <code>ARRAY</code>, but takes an index as an argument to get only one element, rather than a list of all of them.</p> </dd> <dt id="OFF"><a class="permalink" href="#OFF">#</a>OFF</dt> <dd> <p>This method is deprecated if running under Perl 5.8, and is no longer present if running under Perl 5.9</p> </dd> <dt id="AvFLAGS"><a class="permalink" href="#AvFLAGS">#</a>AvFLAGS</dt> <dd> <p>This method returns the AV specific flags. In Perl 5.9 these are now stored in with the main SV flags, so this method is no longer present.</p> </dd> </dl> <h2 id="B::CV-Methods"><a class="permalink" href="#B::CV-Methods">#</a><a id="B12"></a>B::CV Methods</h2> <dl> <dt id="STASH1"><a class="permalink" href="#STASH1">#</a>STASH</dt> <dd> </dd> <dt id="START"><a class="permalink" href="#START">#</a>START</dt> <dd> </dd> <dt id="ROOT"><a class="permalink" href="#ROOT">#</a>ROOT</dt> <dd> </dd> <dt id="GV"><a class="permalink" href="#GV">#</a>GV</dt> <dd> </dd> <dt id="FILE1"><a class="permalink" href="#FILE1">#</a>FILE</dt> <dd> </dd> <dt id="DEPTH"><a class="permalink" href="#DEPTH">#</a>DEPTH</dt> <dd> </dd> <dt id="PADLIST"><a class="permalink" href="#PADLIST">#</a>PADLIST</dt> <dd> </dd> <dt id="OUTSIDE"><a class="permalink" href="#OUTSIDE">#</a>OUTSIDE</dt> <dd> </dd> <dt id="OUTSIDE_SEQ"><a class="permalink" href="#OUTSIDE_SEQ">#</a>OUTSIDE_SEQ</dt> <dd> </dd> <dt id="XSUB"><a class="permalink" href="#XSUB">#</a>XSUB</dt> <dd> </dd> <dt id="XSUBANY"><a class="permalink" href="#XSUBANY">#</a>XSUBANY</dt> <dd> <p>For constant subroutines, returns the constant SV returned by the subroutine.</p> </dd> <dt id="CvFLAGS"><a class="permalink" href="#CvFLAGS">#</a>CvFLAGS</dt> <dd> </dd> <dt id="const_sv"><a class="permalink" href="#const_sv">#</a>const_sv</dt> <dd> </dd> <dt id="NAME_HEK"><a class="permalink" href="#NAME_HEK">#</a>NAME_HEK</dt> <dd> <p>Returns the name of a lexical sub, otherwise <code>undef</code>.</p> </dd> </dl> <h2 id="B::HV-Methods"><a class="permalink" href="#B::HV-Methods">#</a><a id="B13"></a>B::HV Methods</h2> <dl> <dt id="FILL1"><a class="permalink" href="#FILL1">#</a>FILL</dt> <dd> </dd> <dt id="MAX1"><a class="permalink" href="#MAX1">#</a>MAX</dt> <dd> </dd> <dt id="KEYS"><a class="permalink" href="#KEYS">#</a>KEYS</dt> <dd> </dd> <dt id="RITER"><a class="permalink" href="#RITER">#</a>RITER</dt> <dd> </dd> <dt id="NAME2"><a class="permalink" href="#NAME2">#</a>NAME</dt> <dd> </dd> <dt id="ARRAY1"><a class="permalink" href="#ARRAY1">#</a>ARRAY</dt> <dd> </dd> <dt id="PMROOT"><a class="permalink" href="#PMROOT">#</a>PMROOT</dt> <dd> <p>This method is not present if running under Perl 5.9, as the PMROOT information is no longer stored directly in the hash.</p> </dd> </dl> <h2 id="OP-RELATED-CLASSES"><a class="permalink" href="#OP-RELATED-CLASSES">#</a><a id="OP"></a>OP-RELATED CLASSES</h2> <p><code>B::OP</code>, <code>B::UNOP</code>, <code>B::BINOP</code>, <code>B::LOGOP</code>, <code>B::LISTOP</code>, <code>B::PMOP</code>, <code>B::SVOP</code>, <code>B::PADOP</code>, <code>B::PVOP</code>, <code>B::LOOP</code>, <code>B::COP</code>.</p> <p>These classes correspond in the obvious way to the underlying C structures of similar names. The inheritance hierarchy mimics the underlying C &quot;inheritance&quot;:</p> <pre><code class="plaintext"> B::OP | +---------------+--------+--------+-------+ | | | | | B::UNOP B::SVOP B::PADOP B::COP B::PVOP ,&#39; `-. / `--. B::BINOP B::LOGOP | | B::LISTOP ,&#39; `. / \ B::LOOP B::PMOP</code></pre> <p>Access methods correspond to the underlying C structre field names, with the leading &quot;class indication&quot; prefix (<code>&quot;op_&quot;</code>) removed.</p> <h2 id="B::OP-Methods"><a class="permalink" href="#B::OP-Methods">#</a><a id="B14"></a>B::OP Methods</h2> <p>These methods get the values of similarly named fields within the OP data structure. See top of <code>op.h</code> for more info.</p> <dl> <dt id="next"><a class="permalink" href="#next">#</a>next</dt> <dd> </dd> <dt id="sibling"><a class="permalink" href="#sibling">#</a>sibling</dt> <dd> </dd> <dt id="name"><a class="permalink" href="#name">#</a>name</dt> <dd> <p>This returns the op name as a string (e.g. &quot;add&quot;, &quot;rv2av&quot;).</p> </dd> <dt id="ppaddr"><a class="permalink" href="#ppaddr">#</a>ppaddr</dt> <dd> <p>This returns the function name as a string (e.g. &quot;PL_ppaddr[OP_ADD]&quot;, &quot;PL_ppaddr[OP_RV2AV]&quot;).</p> </dd> <dt id="desc"><a class="permalink" href="#desc">#</a>desc</dt> <dd> <p>This returns the op description from the global C PL_op_desc array (e.g. &quot;addition&quot; &quot;array deref&quot;).</p> </dd> <dt id="targ"><a class="permalink" href="#targ">#</a>targ</dt> <dd> </dd> <dt id="type"><a class="permalink" href="#type">#</a>type</dt> <dd> </dd> <dt id="opt"><a class="permalink" href="#opt">#</a>opt</dt> <dd> </dd> <dt id="flags"><a class="permalink" href="#flags">#</a>flags</dt> <dd> </dd> <dt id="private"><a class="permalink" href="#private">#</a>private</dt> <dd> </dd> <dt id="spare"><a class="permalink" href="#spare">#</a>spare</dt> <dd> </dd> </dl> <h2 id="B::UNOP-METHOD"><a class="permalink" href="#B::UNOP-METHOD">#</a><a id="B15"></a>B::UNOP METHOD</h2> <dl> <dt id="first"><a class="permalink" href="#first">#</a>first</dt> <dd> </dd> </dl> <h2 id="B::BINOP-METHOD"><a class="permalink" href="#B::BINOP-METHOD">#</a><a id="B16"></a>B::BINOP METHOD</h2> <dl> <dt id="last"><a class="permalink" href="#last">#</a>last</dt> <dd> </dd> </dl> <h2 id="B::LOGOP-METHOD"><a class="permalink" href="#B::LOGOP-METHOD">#</a><a id="B17"></a>B::LOGOP METHOD</h2> <dl> <dt id="other"><a class="permalink" href="#other">#</a>other</dt> <dd> </dd> </dl> <h2 id="B::LISTOP-METHOD"><a class="permalink" href="#B::LISTOP-METHOD">#</a><a id="B18"></a>B::LISTOP METHOD</h2> <dl> <dt id="children"><a class="permalink" href="#children">#</a>children</dt> <dd> </dd> </dl> <h2 id="B::PMOP-Methods"><a class="permalink" href="#B::PMOP-Methods">#</a><a id="B19"></a>B::PMOP Methods</h2> <dl> <dt id="pmreplroot"><a class="permalink" href="#pmreplroot">#</a>pmreplroot</dt> <dd> </dd> <dt id="pmreplstart"><a class="permalink" href="#pmreplstart">#</a>pmreplstart</dt> <dd> </dd> <dt id="pmnext"><a class="permalink" href="#pmnext">#</a>pmnext</dt> <dd> <p>Only up to Perl 5.9.4</p> </dd> <dt id="pmflags"><a class="permalink" href="#pmflags">#</a>pmflags</dt> <dd> </dd> <dt id="extflags"><a class="permalink" href="#extflags">#</a>extflags</dt> <dd> <p>Since Perl 5.9.5</p> </dd> <dt id="precomp1"><a class="permalink" href="#precomp1">#</a>precomp</dt> <dd> </dd> <dt id="pmoffset"><a class="permalink" href="#pmoffset">#</a>pmoffset</dt> <dd> <p>Only when perl was compiled with ithreads.</p> </dd> <dt id="code_list"><a class="permalink" href="#code_list">#</a>code_list</dt> <dd> <p>Since perl 5.17.1</p> </dd> </dl> <h2 id="B::SVOP-METHOD"><a class="permalink" href="#B::SVOP-METHOD">#</a><a id="B20"></a>B::SVOP METHOD</h2> <dl> <dt id="sv"><a class="permalink" href="#sv">#</a>sv</dt> <dd> </dd> <dt id="gv"><a class="permalink" href="#gv">#</a>gv</dt> <dd> </dd> </dl> <h2 id="B::PADOP-METHOD"><a class="permalink" href="#B::PADOP-METHOD">#</a><a id="B21"></a>B::PADOP METHOD</h2> <dl> <dt id="padix"><a class="permalink" href="#padix">#</a>padix</dt> <dd> </dd> </dl> <h2 id="B::PVOP-METHOD"><a class="permalink" href="#B::PVOP-METHOD">#</a><a id="B22"></a>B::PVOP METHOD</h2> <dl> <dt id="pv"><a class="permalink" href="#pv">#</a>pv</dt> <dd> </dd> </dl> <h2 id="B::LOOP-Methods"><a class="permalink" href="#B::LOOP-Methods">#</a><a id="B23"></a>B::LOOP Methods</h2> <dl> <dt id="redoop"><a class="permalink" href="#redoop">#</a>redoop</dt> <dd> </dd> <dt id="nextop"><a class="permalink" href="#nextop">#</a>nextop</dt> <dd> </dd> <dt id="lastop"><a class="permalink" href="#lastop">#</a>lastop</dt> <dd> </dd> </dl> <h2 id="B::COP-Methods"><a class="permalink" href="#B::COP-Methods">#</a><a id="B24"></a>B::COP Methods</h2> <dl> <dt id="label"><a class="permalink" href="#label">#</a>label</dt> <dd> </dd> <dt id="stash"><a class="permalink" href="#stash">#</a>stash</dt> <dd> </dd> <dt id="stashpv"><a class="permalink" href="#stashpv">#</a>stashpv</dt> <dd> </dd> <dt id="stashoff-(threaded-only)"><a class="permalink" href="#stashoff-(threaded-only)">#</a><a id="stashoff"></a><a id="stashoff-threaded-only"></a>stashoff (threaded only)</dt> <dd> </dd> <dt id="file"><a class="permalink" href="#file">#</a>file</dt> <dd> </dd> <dt id="cop_seq"><a class="permalink" href="#cop_seq">#</a>cop_seq</dt> <dd> </dd> <dt id="arybase"><a class="permalink" href="#arybase">#</a>arybase</dt> <dd> </dd> <dt id="line"><a class="permalink" href="#line">#</a>line</dt> <dd> </dd> <dt id="warnings"><a class="permalink" href="#warnings">#</a>warnings</dt> <dd> </dd> <dt id="io"><a class="permalink" href="#io">#</a>io</dt> <dd> </dd> <dt id="hints"><a class="permalink" href="#hints">#</a>hints</dt> <dd> </dd> <dt id="hints_hash"><a class="permalink" href="#hints_hash">#</a>hints_hash</dt> <dd> </dd> </dl> <h2 id="$B::overlay"><a class="permalink" href="#$B::overlay">#</a><a id="B::overlay"></a>$B::overlay</h2> <p>Although the optree is read-only, there is an overlay facility that allows you to override what values the various B::*OP methods return for a particular op. <code>$B::overlay</code> should be set to reference a two-deep hash: indexed by OP address, then method name. Whenever a an op method is called, the value in the hash is returned if it exists. This facility is used by B::Deparse to &quot;undo&quot; some optimisations. For example:</p> <pre><code>local $B::overlay = {}; ... if ($op-&gt;name eq &quot;foo&quot;) { $B::overlay-&gt;{$$op} = { name =&gt; &#39;bar&#39;, next =&gt; $op-&gt;next-&gt;next, }; } ... $op-&gt;name # returns &quot;bar&quot; $op-&gt;next # returns the next op but one</code></pre> <h1 id="AUTHOR"><a class="permalink" href="#AUTHOR">#</a>AUTHOR</h1> <p>Malcolm Beattie, <code>mbeattie@sable.ox.ac.uk</code></p> </div> <div id="footer"> <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p> <p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> <script src="/js/highlight.pack.js"></script> <script>hljs.highlightAll();</script> </body> </html>

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