CINXE.COM
perlapi - autogenerated documentation for the perl public API - 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>perlapi - autogenerated documentation for the perl public API - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/perlapi"> <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.8.1</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/perlapi">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1/perlapi">5.40.1</a> <a class="dropdown-item" href="/5.40.0/perlapi">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3/perlapi">5.38.3</a> <a class="dropdown-item" href="/5.38.2/perlapi">5.38.2</a> <a class="dropdown-item" href="/5.38.1/perlapi">5.38.1</a> <a class="dropdown-item" href="/5.38.0/perlapi">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/perlapi">5.36.3</a> <a class="dropdown-item" href="/5.36.2/perlapi">5.36.2</a> <a class="dropdown-item" href="/5.36.1/perlapi">5.36.1</a> <a class="dropdown-item" href="/5.36.0/perlapi">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/perlapi">5.34.3</a> <a class="dropdown-item" href="/5.34.2/perlapi">5.34.2</a> <a class="dropdown-item" href="/5.34.1/perlapi">5.34.1</a> <a class="dropdown-item" href="/5.34.0/perlapi">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/perlapi">5.32.1</a> <a class="dropdown-item" href="/5.32.0/perlapi">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/perlapi">5.30.3</a> <a class="dropdown-item" href="/5.30.2/perlapi">5.30.2</a> <a class="dropdown-item" href="/5.30.1/perlapi">5.30.1</a> <a class="dropdown-item" href="/5.30.0/perlapi">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/perlapi">5.28.3</a> <a class="dropdown-item" href="/5.28.2/perlapi">5.28.2</a> <a class="dropdown-item" href="/5.28.1/perlapi">5.28.1</a> <a class="dropdown-item" href="/5.28.0/perlapi">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/perlapi">5.26.3</a> <a class="dropdown-item" href="/5.26.2/perlapi">5.26.2</a> <a class="dropdown-item" href="/5.26.1/perlapi">5.26.1</a> <a class="dropdown-item" href="/5.26.0/perlapi">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/perlapi">5.24.4</a> <a class="dropdown-item" href="/5.24.3/perlapi">5.24.3</a> <a class="dropdown-item" href="/5.24.2/perlapi">5.24.2</a> <a class="dropdown-item" href="/5.24.1/perlapi">5.24.1</a> <a class="dropdown-item" href="/5.24.0/perlapi">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/perlapi">5.22.4</a> <a class="dropdown-item" href="/5.22.3/perlapi">5.22.3</a> <a class="dropdown-item" href="/5.22.2/perlapi">5.22.2</a> <a class="dropdown-item" href="/5.22.1/perlapi">5.22.1</a> <a class="dropdown-item" href="/5.22.0/perlapi">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/perlapi">5.20.3</a> <a class="dropdown-item" href="/5.20.2/perlapi">5.20.2</a> <a class="dropdown-item" href="/5.20.1/perlapi">5.20.1</a> <a class="dropdown-item" href="/5.20.0/perlapi">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/perlapi">5.18.4</a> <a class="dropdown-item" href="/5.18.3/perlapi">5.18.3</a> <a class="dropdown-item" href="/5.18.2/perlapi">5.18.2</a> <a class="dropdown-item" href="/5.18.1/perlapi">5.18.1</a> <a class="dropdown-item" href="/5.18.0/perlapi">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/perlapi">5.16.3</a> <a class="dropdown-item" href="/5.16.2/perlapi">5.16.2</a> <a class="dropdown-item" href="/5.16.1/perlapi">5.16.1</a> <a class="dropdown-item" href="/5.16.0/perlapi">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/perlapi">5.14.4</a> <a class="dropdown-item" href="/5.14.3/perlapi">5.14.3</a> <a class="dropdown-item" href="/5.14.2/perlapi">5.14.2</a> <a class="dropdown-item" href="/5.14.1/perlapi">5.14.1</a> <a class="dropdown-item" href="/5.14.0/perlapi">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/perlapi">5.12.5</a> <a class="dropdown-item" href="/5.12.4/perlapi">5.12.4</a> <a class="dropdown-item" href="/5.12.3/perlapi">5.12.3</a> <a class="dropdown-item" href="/5.12.2/perlapi">5.12.2</a> <a class="dropdown-item" href="/5.12.1/perlapi">5.12.1</a> <a class="dropdown-item" href="/5.12.0/perlapi">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/perlapi">5.10.1</a> <a class="dropdown-item" href="/5.10.0/perlapi">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/perlapi">5.8.9</a> <a class="dropdown-item" href="/5.8.8/perlapi">5.8.8</a> <a class="dropdown-item" href="/5.8.7/perlapi">5.8.7</a> <a class="dropdown-item" href="/5.8.6/perlapi">5.8.6</a> <a class="dropdown-item" href="/5.8.5/perlapi">5.8.5</a> <a class="dropdown-item" href="/5.8.4/perlapi">5.8.4</a> <a class="dropdown-item" href="/5.8.3/perlapi">5.8.3</a> <a class="dropdown-item" href="/5.8.2/perlapi">5.8.2</a> <a class="dropdown-item active" href="/5.8.1/perlapi">5.8.1</a> <a class="dropdown-item" href="/5.8.0/perlapi">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/perlapi">5.6.2</a> <a class="dropdown-item" href="/5.6.1/perlapi">5.6.1</a> <a class="dropdown-item" href="/5.6.0/perlapi">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/perlapi">5.005_04</a> <a class="dropdown-item" href="/5.005_03/perlapi">5.005_03</a> <a class="dropdown-item" href="/5.005_02/perlapi">5.005_02</a> <a class="dropdown-item" href="/5.005_01/perlapi">5.005_01</a> <a class="dropdown-item" href="/5.005/perlapi">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/perlapi">blead</a> <a class="dropdown-item" href="/5.41.9/perlapi">5.41.9</a> <a class="dropdown-item" href="/5.41.8/perlapi">5.41.8</a> <a class="dropdown-item" href="/5.41.7/perlapi">5.41.7</a> <a class="dropdown-item" href="/5.41.6/perlapi">5.41.6</a> <a class="dropdown-item" href="/5.41.5/perlapi">5.41.5</a> <a class="dropdown-item" href="/5.41.4/perlapi">5.41.4</a> <a class="dropdown-item" href="/5.41.3/perlapi">5.41.3</a> <a class="dropdown-item" href="/5.41.2/perlapi">5.41.2</a> <a class="dropdown-item" href="/5.41.1/perlapi">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1-RC1/perlapi">5.40.1-RC1</a> <a class="dropdown-item" href="/5.40.0-RC2/perlapi">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/perlapi">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/perlapi">5.39.10</a> <a class="dropdown-item" href="/5.39.9/perlapi">5.39.9</a> <a class="dropdown-item" href="/5.39.8/perlapi">5.39.8</a> <a class="dropdown-item" href="/5.39.7/perlapi">5.39.7</a> <a class="dropdown-item" href="/5.39.6/perlapi">5.39.6</a> <a class="dropdown-item" href="/5.39.5/perlapi">5.39.5</a> <a class="dropdown-item" href="/5.39.4/perlapi">5.39.4</a> <a class="dropdown-item" href="/5.39.3/perlapi">5.39.3</a> <a class="dropdown-item" href="/5.39.2/perlapi">5.39.2</a> <a class="dropdown-item" href="/5.39.1/perlapi">5.39.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3-RC1/perlapi">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.8.1/perl">Perl</a> <a class="dropdown-item" href="/5.8.1/perlintro">Intro</a> <a class="dropdown-item" href="/5.8.1/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.8.1/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.8.1/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.1/perlop">Operators</a> <a class="dropdown-item" href="/5.8.1/functions">Functions</a> <a class="dropdown-item" href="/5.8.1/variables">Variables</a> <a class="dropdown-item" href="/5.8.1/modules">Modules</a> <a class="dropdown-item" href="/5.8.1/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.1/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.8.1/perlcommunity">Community</a> <a class="dropdown-item" href="/5.8.1/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.8.1/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.8.1/perlapi">perlapi</a> <div id="more"> (<a href="/5.8.1/perlapi.txt">source</a>, <a href="https://metacpan.org/pod/perlapi">CPAN</a>) </div> </div> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.8.1. <a href="/perlapi">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> </li> <li> <a class="text-decoration-none" href="#%22Gimme%22-Values">"Gimme" Values</a> </li> <li> <a class="text-decoration-none" href="#Array-Manipulation-Functions">Array Manipulation Functions</a> </li> <li> <a class="text-decoration-none" href="#Callback-Functions">Callback Functions</a> </li> <li> <a class="text-decoration-none" href="#Character-classes">Character classes</a> </li> <li> <a class="text-decoration-none" href="#Cloning-an-interpreter">Cloning an interpreter</a> </li> <li> <a class="text-decoration-none" href="#CV-Manipulation-Functions">CV Manipulation Functions</a> </li> <li> <a class="text-decoration-none" href="#Embedding-Functions">Embedding Functions</a> </li> <li> <a class="text-decoration-none" href="#Functions-in-file-pp_pack.c">Functions in file pp_pack.c</a> </li> <li> <a class="text-decoration-none" href="#Global-Variables">Global Variables</a> </li> <li> <a class="text-decoration-none" href="#GV-Functions">GV Functions</a> </li> <li> <a class="text-decoration-none" href="#Handy-Values">Handy Values</a> </li> <li> <a class="text-decoration-none" href="#Hash-Manipulation-Functions">Hash Manipulation Functions</a> </li> <li> <a class="text-decoration-none" href="#Magical-Functions">Magical Functions</a> </li> <li> <a class="text-decoration-none" href="#Memory-Management">Memory Management</a> </li> <li> <a class="text-decoration-none" href="#Miscellaneous-Functions">Miscellaneous Functions</a> </li> <li> <a class="text-decoration-none" href="#Numeric-functions">Numeric functions</a> </li> <li> <a class="text-decoration-none" href="#Optree-Manipulation-Functions">Optree Manipulation Functions</a> </li> <li> <a class="text-decoration-none" href="#Pad-Data-Structures">Pad Data Structures</a> </li> <li> <a class="text-decoration-none" href="#Stack-Manipulation-Macros">Stack Manipulation Macros</a> </li> <li> <a class="text-decoration-none" href="#SV-Flags">SV Flags</a> </li> <li> <a class="text-decoration-none" href="#SV-Manipulation-Functions">SV Manipulation Functions</a> </li> <li> <a class="text-decoration-none" href="#Unicode-Support">Unicode Support</a> </li> <li> <a class="text-decoration-none" href="#Variables-created-by-xsubpp-and-xsubpp-internal-functions">Variables created by xsubpp and xsubpp internal functions</a> </li> <li> <a class="text-decoration-none" href="#Warning-and-Dieing">Warning and Dieing</a> </li> <li> <a class="text-decoration-none" href="#AUTHORS">AUTHORS</a> </li> <li> <a class="text-decoration-none" href="#SEE-ALSO">SEE ALSO</a> </li> </ul> <h1 id="NAME"><a class="permalink" href="#NAME">#</a>NAME</h1> <p>perlapi - autogenerated documentation for the perl public API</p> <h1 id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">#</a>DESCRIPTION</h1> <p>This file contains the documentation of the perl public API generated by embed.pl, specifically a listing of functions, macros, flags, and variables that may be used by extension writers. The interfaces of any functions that are not listed here are subject to change without notice. For this reason, blindly using functions listed in proto.h is to be avoided when writing extensions.</p> <p>Note that all Perl API global variables must be referenced with the <code>PL_</code> prefix. Some macros are provided for compatibility with the older, unadorned names, but this support may be disabled in a future release.</p> <p>The listing is alphabetical, case insensitive.</p> <h1 id=""Gimme"-Values"><a class="permalink" href="#%22Gimme%22-Values">#</a><a id="Gimme-Values"></a>"Gimme" Values</h1> <dl> <dt id="GIMME"><a class="permalink" href="#GIMME">#</a>GIMME</dt> <dd> <p>A backward-compatible version of <code>GIMME_V</code> which can only return <code>G_SCALAR</code> or <code>G_ARRAY</code>; in a void context, it returns <code>G_SCALAR</code>. Deprecated. Use <code>GIMME_V</code> instead.</p> <pre><code class="plaintext">U32 GIMME</code></pre> </dd> <dt id="GIMME_V"><a class="permalink" href="#GIMME_V">#</a>GIMME_V</dt> <dd> <p>The XSUB-writer's equivalent to Perl's <code>wantarray</code>. Returns <code>G_VOID</code>, <code>G_SCALAR</code> or <code>G_ARRAY</code> for void, scalar or list context, respectively.</p> <pre><code class="plaintext">U32 GIMME_V</code></pre> </dd> <dt id="G_ARRAY"><a class="permalink" href="#G_ARRAY">#</a>G_ARRAY</dt> <dd> <p>Used to indicate list context. See <code>GIMME_V</code>, <code>GIMME</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> <dt id="G_DISCARD"><a class="permalink" href="#G_DISCARD">#</a>G_DISCARD</dt> <dd> <p>Indicates that arguments returned from a callback should be discarded. See <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> <dt id="G_EVAL"><a class="permalink" href="#G_EVAL">#</a>G_EVAL</dt> <dd> <p>Used to force a Perl <code>eval</code> wrapper around a callback. See <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> <dt id="G_NOARGS"><a class="permalink" href="#G_NOARGS">#</a>G_NOARGS</dt> <dd> <p>Indicates that no arguments are being sent to a callback. See <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> <dt id="G_SCALAR"><a class="permalink" href="#G_SCALAR">#</a>G_SCALAR</dt> <dd> <p>Used to indicate scalar context. See <code>GIMME_V</code>, <code>GIMME</code>, and <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> <dt id="G_VOID"><a class="permalink" href="#G_VOID">#</a>G_VOID</dt> <dd> <p>Used to indicate void context. See <code>GIMME_V</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> </dd> </dl> <h1 id="Array-Manipulation-Functions"><a class="permalink" href="#Array-Manipulation-Functions">#</a><a id="Array"></a>Array Manipulation Functions</h1> <dl> <dt id="AvFILL"><a class="permalink" href="#AvFILL">#</a>AvFILL</dt> <dd> <p>Same as <code>av_len()</code>. Deprecated, use <code>av_len()</code> instead.</p> <pre><code class="plaintext">int AvFILL(AV* av)</code></pre> </dd> <dt id="av_clear"><a class="permalink" href="#av_clear">#</a>av_clear</dt> <dd> <p>Clears an array, making it empty. Does not free the memory used by the array itself.</p> <pre><code class="plaintext">void av_clear(AV* ar)</code></pre> </dd> <dt id="av_delete"><a class="permalink" href="#av_delete">#</a>av_delete</dt> <dd> <p>Deletes the element indexed by <code>key</code> from the array. Returns the deleted element. <code>flags</code> is currently ignored.</p> <pre><code class="plaintext">SV* av_delete(AV* ar, I32 key, I32 flags)</code></pre> </dd> <dt id="av_exists"><a class="permalink" href="#av_exists">#</a>av_exists</dt> <dd> <p>Returns true if the element indexed by <code>key</code> has been initialized.</p> <p>This relies on the fact that uninitialized array elements are set to <code>&PL_sv_undef</code>.</p> <pre><code class="plaintext">bool av_exists(AV* ar, I32 key)</code></pre> </dd> <dt id="av_extend"><a class="permalink" href="#av_extend">#</a>av_extend</dt> <dd> <p>Pre-extend an array. The <code>key</code> is the index to which the array should be extended.</p> <pre><code class="plaintext">void av_extend(AV* ar, I32 key)</code></pre> </dd> <dt id="av_fetch"><a class="permalink" href="#av_fetch">#</a>av_fetch</dt> <dd> <p>Returns the SV at the specified index in the array. The <code>key</code> is the index. If <code>lval</code> is set then the fetch will be part of a store. Check that the return value is non-null before dereferencing it to a <code>SV*</code>.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied arrays.</p> <pre><code class="plaintext">SV** av_fetch(AV* ar, I32 key, I32 lval)</code></pre> </dd> <dt id="av_fill"><a class="permalink" href="#av_fill">#</a>av_fill</dt> <dd> <p>Ensure than an array has a given number of elements, equivalent to Perl's <code>$#array = $fill;</code>.</p> <pre><code class="plaintext">void av_fill(AV* ar, I32 fill)</code></pre> </dd> <dt id="av_len"><a class="permalink" href="#av_len">#</a>av_len</dt> <dd> <p>Returns the highest index in the array. Returns -1 if the array is empty.</p> <pre><code class="plaintext">I32 av_len(AV* ar)</code></pre> </dd> <dt id="av_make"><a class="permalink" href="#av_make">#</a>av_make</dt> <dd> <p>Creates a new AV and populates it with a list of SVs. The SVs are copied into the array, so they may be freed after the call to av_make. The new AV will have a reference count of 1.</p> <pre><code class="plaintext">AV* av_make(I32 size, SV** svp)</code></pre> </dd> <dt id="av_pop"><a class="permalink" href="#av_pop">#</a>av_pop</dt> <dd> <p>Pops an SV off the end of the array. Returns <code>&PL_sv_undef</code> if the array is empty.</p> <pre><code class="plaintext">SV* av_pop(AV* ar)</code></pre> </dd> <dt id="av_push"><a class="permalink" href="#av_push">#</a>av_push</dt> <dd> <p>Pushes an SV onto the end of the array. The array will grow automatically to accommodate the addition.</p> <pre><code class="plaintext">void av_push(AV* ar, SV* val)</code></pre> </dd> <dt id="av_shift"><a class="permalink" href="#av_shift">#</a>av_shift</dt> <dd> <p>Shifts an SV off the beginning of the array.</p> <pre><code class="plaintext">SV* av_shift(AV* ar)</code></pre> </dd> <dt id="av_store"><a class="permalink" href="#av_store">#</a>av_store</dt> <dd> <p>Stores an SV in an array. The array index is specified as <code>key</code>. The return value will be NULL if the operation failed or if the value did not need to be actually stored within the array (as in the case of tied arrays). Otherwise it can be dereferenced to get the original <code>SV*</code>. Note that the caller is responsible for suitably incrementing the reference count of <code>val</code> before the call, and decrementing it if the function returned NULL.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied arrays.</p> <pre><code class="plaintext">SV** av_store(AV* ar, I32 key, SV* val)</code></pre> </dd> <dt id="av_undef"><a class="permalink" href="#av_undef">#</a>av_undef</dt> <dd> <p>Undefines the array. Frees the memory used by the array itself.</p> <pre><code class="plaintext">void av_undef(AV* ar)</code></pre> </dd> <dt id="av_unshift"><a class="permalink" href="#av_unshift">#</a>av_unshift</dt> <dd> <p>Unshift the given number of <code>undef</code> values onto the beginning of the array. The array will grow automatically to accommodate the addition. You must then use <code>av_store</code> to assign values to these new elements.</p> <pre><code class="plaintext">void av_unshift(AV* ar, I32 num)</code></pre> </dd> <dt id="get_av"><a class="permalink" href="#get_av">#</a>get_av</dt> <dd> <p>Returns the AV of the specified Perl array. If <code>create</code> is set and the Perl variable does not exist then it will be created. If <code>create</code> is not set and the variable does not exist then NULL is returned.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">AV* get_av(const char* name, I32 create)</code></pre> </dd> <dt id="newAV"><a class="permalink" href="#newAV">#</a>newAV</dt> <dd> <p>Creates a new AV. The reference count is set to 1.</p> <pre><code class="plaintext">AV* newAV()</code></pre> </dd> <dt id="Nullav"><a class="permalink" href="#Nullav">#</a>Nullav</dt> <dd> <p>Null AV pointer.</p> </dd> <dt id="sortsv"><a class="permalink" href="#sortsv">#</a>sortsv</dt> <dd> <p>Sort an array. Here is an example:</p> <pre><code>sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);</code></pre> <p>See lib/sort.pm for details about controlling the sorting algorithm.</p> <pre><code class="plaintext">void sortsv(SV ** array, size_t num_elts, SVCOMPARE_t cmp)</code></pre> </dd> </dl> <h1 id="Callback-Functions"><a class="permalink" href="#Callback-Functions">#</a><a id="Callback"></a>Callback Functions</h1> <dl> <dt id="call_argv"><a class="permalink" href="#call_argv">#</a>call_argv</dt> <dd> <p>Performs a callback to the specified Perl sub. See <a href="/5.8.1/perlcall">perlcall</a>.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">I32 call_argv(const char* sub_name, I32 flags, char** argv)</code></pre> </dd> <dt id="call_method"><a class="permalink" href="#call_method">#</a>call_method</dt> <dd> <p>Performs a callback to the specified Perl method. The blessed object must be on the stack. See <a href="/5.8.1/perlcall">perlcall</a>.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">I32 call_method(const char* methname, I32 flags)</code></pre> </dd> <dt id="call_pv"><a class="permalink" href="#call_pv">#</a>call_pv</dt> <dd> <p>Performs a callback to the specified Perl sub. See <a href="/5.8.1/perlcall">perlcall</a>.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">I32 call_pv(const char* sub_name, I32 flags)</code></pre> </dd> <dt id="call_sv"><a class="permalink" href="#call_sv">#</a>call_sv</dt> <dd> <p>Performs a callback to the Perl sub whose name is in the SV. See <a href="/5.8.1/perlcall">perlcall</a>.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">I32 call_sv(SV* sv, I32 flags)</code></pre> </dd> <dt id="ENTER"><a class="permalink" href="#ENTER">#</a>ENTER</dt> <dd> <p>Opening bracket on a callback. See <code>LEAVE</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>ENTER;</code></pre> </dd> <dt id="eval_pv"><a class="permalink" href="#eval_pv">#</a>eval_pv</dt> <dd> <p>Tells Perl to <code>eval</code> the given string and return an SV* result.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">SV* eval_pv(const char* p, I32 croak_on_error)</code></pre> </dd> <dt id="eval_sv"><a class="permalink" href="#eval_sv">#</a>eval_sv</dt> <dd> <p>Tells Perl to <code>eval</code> the string in the SV.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">I32 eval_sv(SV* sv, I32 flags)</code></pre> </dd> <dt id="FREETMPS"><a class="permalink" href="#FREETMPS">#</a>FREETMPS</dt> <dd> <p>Closing bracket for temporaries on a callback. See <code>SAVETMPS</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>FREETMPS;</code></pre> </dd> <dt id="LEAVE"><a class="permalink" href="#LEAVE">#</a>LEAVE</dt> <dd> <p>Closing bracket on a callback. See <code>ENTER</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>LEAVE;</code></pre> </dd> <dt id="SAVETMPS"><a class="permalink" href="#SAVETMPS">#</a>SAVETMPS</dt> <dd> <p>Opening bracket for temporaries on a callback. See <code>FREETMPS</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>SAVETMPS;</code></pre> </dd> </dl> <h1 id="Character-classes"><a class="permalink" href="#Character-classes">#</a><a id="Character"></a>Character classes</h1> <dl> <dt id="isALNUM"><a class="permalink" href="#isALNUM">#</a>isALNUM</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is an ASCII alphanumeric character (including underscore) or digit.</p> <pre><code class="plaintext">bool isALNUM(char ch)</code></pre> </dd> <dt id="isALPHA"><a class="permalink" href="#isALPHA">#</a>isALPHA</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is an ASCII alphabetic character.</p> <pre><code class="plaintext">bool isALPHA(char ch)</code></pre> </dd> <dt id="isDIGIT"><a class="permalink" href="#isDIGIT">#</a>isDIGIT</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is an ASCII digit.</p> <pre><code class="plaintext">bool isDIGIT(char ch)</code></pre> </dd> <dt id="isLOWER"><a class="permalink" href="#isLOWER">#</a>isLOWER</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is a lowercase character.</p> <pre><code class="plaintext">bool isLOWER(char ch)</code></pre> </dd> <dt id="isSPACE"><a class="permalink" href="#isSPACE">#</a>isSPACE</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is whitespace.</p> <pre><code class="plaintext">bool isSPACE(char ch)</code></pre> </dd> <dt id="isUPPER"><a class="permalink" href="#isUPPER">#</a>isUPPER</dt> <dd> <p>Returns a boolean indicating whether the C <code>char</code> is an uppercase character.</p> <pre><code class="plaintext">bool isUPPER(char ch)</code></pre> </dd> <dt id="toLOWER"><a class="permalink" href="#toLOWER">#</a>toLOWER</dt> <dd> <p>Converts the specified character to lowercase.</p> <pre><code class="plaintext">char toLOWER(char ch)</code></pre> </dd> <dt id="toUPPER"><a class="permalink" href="#toUPPER">#</a>toUPPER</dt> <dd> <p>Converts the specified character to uppercase.</p> <pre><code class="plaintext">char toUPPER(char ch)</code></pre> </dd> </dl> <h1 id="Cloning-an-interpreter"><a class="permalink" href="#Cloning-an-interpreter">#</a><a id="Cloning"></a>Cloning an interpreter</h1> <dl> <dt id="perl_clone"><a class="permalink" href="#perl_clone">#</a>perl_clone</dt> <dd> <p>Create and return a new interpreter by cloning the current one.</p> <p>perl_clone takes these flags as parameters:</p> <p>CLONEf_COPY_STACKS - is used to, well, copy the stacks also, without it we only clone the data and zero the stacks, with it we copy the stacks and the new perl interpreter is ready to run at the exact same point as the previous one. The pseudo-fork code uses COPY_STACKS while the threads->new doesn't.</p> <p>CLONEf_KEEP_PTR_TABLE perl_clone keeps a ptr_table with the pointer of the old variable as a key and the new variable as a value, this allows it to check if something has been cloned and not clone it again but rather just use the value and increase the refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill the ptr_table using the function <code>ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;</code>, reason to keep it around is if you want to dup some of your own variable who are outside the graph perl scans, example of this code is in threads.xs create</p> <p>CLONEf_CLONE_HOST This is a win32 thing, it is ignored on unix, it tells perls win32host code (which is c++) to clone itself, this is needed on win32 if you want to run two threads at the same time, if you just want to do some stuff in a separate perl interpreter and then throw it away and return to the original one, you don't need to do anything.</p> <pre><code class="plaintext">PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags)</code></pre> </dd> </dl> <h1 id="CV-Manipulation-Functions"><a class="permalink" href="#CV-Manipulation-Functions">#</a><a id="CV"></a>CV Manipulation Functions</h1> <dl> <dt id="CvSTASH"><a class="permalink" href="#CvSTASH">#</a>CvSTASH</dt> <dd> <p>Returns the stash of the CV.</p> <pre><code class="plaintext">HV* CvSTASH(CV* cv)</code></pre> </dd> <dt id="get_cv"><a class="permalink" href="#get_cv">#</a>get_cv</dt> <dd> <p>Returns the CV of the specified Perl subroutine. If <code>create</code> is set and the Perl subroutine does not exist then it will be declared (which has the same effect as saying <code>sub name;</code>). If <code>create</code> is not set and the subroutine does not exist then NULL is returned.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">CV* get_cv(const char* name, I32 create)</code></pre> </dd> <dt id="Nullcv"><a class="permalink" href="#Nullcv">#</a>Nullcv</dt> <dd> <p>Null CV pointer.</p> </dd> </dl> <h1 id="Embedding-Functions"><a class="permalink" href="#Embedding-Functions">#</a><a id="Embedding"></a>Embedding Functions</h1> <dl> <dt id="cv_undef"><a class="permalink" href="#cv_undef">#</a>cv_undef</dt> <dd> <p>Clear out all the active components of a CV. This can happen either by an explicit <code>undef &foo</code>, or by the reference count going to zero. In the former case, we keep the CvOUTSIDE pointer, so that any anonymous children can still follow the full lexical scope chain.</p> <pre><code class="plaintext">void cv_undef(CV* cv)</code></pre> </dd> <dt id="load_module"><a class="permalink" href="#load_module">#</a>load_module</dt> <dd> <p>Loads the module whose name is pointed to by the string part of name. Note that the actual module name, not its filename, should be given. Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS (or 0 for no flags). ver, if specified, provides version semantics similar to <code>use Foo::Bar VERSION</code>. The optional trailing SV* arguments can be used to specify arguments to the module's import() method, similar to <code>use Foo::Bar VERSION LIST</code>.</p> <pre><code class="plaintext">void load_module(U32 flags, SV* name, SV* ver, ...)</code></pre> </dd> <dt id="nothreadhook"><a class="permalink" href="#nothreadhook">#</a>nothreadhook</dt> <dd> <p>Stub that provides thread hook for perl_destruct when there are no threads.</p> <pre><code class="plaintext">int nothreadhook()</code></pre> </dd> <dt id="perl_alloc"><a class="permalink" href="#perl_alloc">#</a>perl_alloc</dt> <dd> <p>Allocates a new Perl interpreter. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">PerlInterpreter* perl_alloc()</code></pre> </dd> <dt id="perl_construct"><a class="permalink" href="#perl_construct">#</a>perl_construct</dt> <dd> <p>Initializes a new Perl interpreter. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">void perl_construct(PerlInterpreter* interp)</code></pre> </dd> <dt id="perl_destruct"><a class="permalink" href="#perl_destruct">#</a>perl_destruct</dt> <dd> <p>Shuts down a Perl interpreter. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">int perl_destruct(PerlInterpreter* interp)</code></pre> </dd> <dt id="perl_free"><a class="permalink" href="#perl_free">#</a>perl_free</dt> <dd> <p>Releases a Perl interpreter. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">void perl_free(PerlInterpreter* interp)</code></pre> </dd> <dt id="perl_parse"><a class="permalink" href="#perl_parse">#</a>perl_parse</dt> <dd> <p>Tells a Perl interpreter to parse a Perl script. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)</code></pre> </dd> <dt id="perl_run"><a class="permalink" href="#perl_run">#</a>perl_run</dt> <dd> <p>Tells a Perl interpreter to run. See <a href="/5.8.1/perlembed">perlembed</a>.</p> <pre><code class="plaintext">int perl_run(PerlInterpreter* interp)</code></pre> </dd> <dt id="require_pv"><a class="permalink" href="#require_pv">#</a>require_pv</dt> <dd> <p>Tells Perl to <code>require</code> the file named by the string argument. It is analogous to the Perl code <code>eval "require '$file'"</code>. It's even implemented that way; consider using load_module instead.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">void require_pv(const char* pv)</code></pre> </dd> </dl> <h1 id="Functions-in-file-pp_pack.c"><a class="permalink" href="#Functions-in-file-pp_pack.c">#</a><a id="Functions"></a>Functions in file pp_pack.c</h1> <dl> <dt id="packlist"><a class="permalink" href="#packlist">#</a>packlist</dt> <dd> <p>The engine implementing pack() Perl function.</p> <pre><code class="plaintext">void packlist(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist)</code></pre> </dd> <dt id="pack_cat"><a class="permalink" href="#pack_cat">#</a>pack_cat</dt> <dd> <p>The engine implementing pack() Perl function. Note: parameters next_in_list and flags are not used. This call should not be used; use packlist instead.</p> <pre><code class="plaintext">void pack_cat(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)</code></pre> </dd> <dt id="unpackstring"><a class="permalink" href="#unpackstring">#</a>unpackstring</dt> <dd> <p>The engine implementing unpack() Perl function.</p> <pre><code class="plaintext">I32 unpackstring(char *pat, char *patend, char *s, char *strend, U32 flags)</code></pre> </dd> <dt id="unpack_str"><a class="permalink" href="#unpack_str">#</a>unpack_str</dt> <dd> <p>The engine implementing unpack() Perl function. Note: parameters strbeg, new_s and ocnt are not used. This call should not be used, use unpackstring instead.</p> <pre><code class="plaintext">I32 unpack_str(char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags)</code></pre> </dd> </dl> <h1 id="Global-Variables"><a class="permalink" href="#Global-Variables">#</a><a id="Global"></a>Global Variables</h1> <dl> <dt id="PL_modglobal"><a class="permalink" href="#PL_modglobal">#</a>PL_modglobal</dt> <dd> <p><code>PL_modglobal</code> is a general purpose, interpreter global HV for use by extensions that need to keep information on a per-interpreter basis. In a pinch, it can also be used as a symbol table for extensions to share data among each other. It is a good idea to use keys prefixed by the package name of the extension that owns the data.</p> <pre><code class="plaintext">HV* PL_modglobal</code></pre> </dd> <dt id="PL_na"><a class="permalink" href="#PL_na">#</a>PL_na</dt> <dd> <p>A convenience variable which is typically used with <code>SvPV</code> when one doesn't care about the length of the string. It is usually more efficient to either declare a local variable and use that instead or to use the <code>SvPV_nolen</code> macro.</p> <pre><code class="plaintext">STRLEN PL_na</code></pre> </dd> <dt id="PL_sv_no"><a class="permalink" href="#PL_sv_no">#</a>PL_sv_no</dt> <dd> <p>This is the <code>false</code> SV. See <code>PL_sv_yes</code>. Always refer to this as <code>&PL_sv_no</code>.</p> <pre><code class="plaintext">SV PL_sv_no</code></pre> </dd> <dt id="PL_sv_undef"><a class="permalink" href="#PL_sv_undef">#</a>PL_sv_undef</dt> <dd> <p>This is the <code>undef</code> SV. Always refer to this as <code>&PL_sv_undef</code>.</p> <pre><code class="plaintext">SV PL_sv_undef</code></pre> </dd> <dt id="PL_sv_yes"><a class="permalink" href="#PL_sv_yes">#</a>PL_sv_yes</dt> <dd> <p>This is the <code>true</code> SV. See <code>PL_sv_no</code>. Always refer to this as <code>&PL_sv_yes</code>.</p> <pre><code class="plaintext">SV PL_sv_yes</code></pre> </dd> </dl> <h1 id="GV-Functions"><a class="permalink" href="#GV-Functions">#</a><a id="GV"></a>GV Functions</h1> <dl> <dt id="GvSV"><a class="permalink" href="#GvSV">#</a>GvSV</dt> <dd> <p>Return the SV from the GV.</p> <pre><code class="plaintext">SV* GvSV(GV* gv)</code></pre> </dd> <dt id="gv_fetchmeth"><a class="permalink" href="#gv_fetchmeth">#</a>gv_fetchmeth</dt> <dd> <p>Returns the glob with the given <code>name</code> and a defined subroutine or <code>NULL</code>. The glob lives in the given <code>stash</code>, or in the stashes accessible via @ISA and UNIVERSAL::.</p> <p>The argument <code>level</code> should be either 0 or -1. If <code>level==0</code>, as a side-effect creates a glob with the given <code>name</code> in the given <code>stash</code> which in the case of success contains an alias for the subroutine, and sets up caching info for this glob. Similarly for all the searched stashes.</p> <p>This function grants <code>"SUPER"</code> token as a postfix of the stash name. The GV returned from <code>gv_fetchmeth</code> may be a method cache entry, which is not visible to Perl code. So when calling <code>call_sv</code>, you should not use the GV directly; instead, you should use the method's CV, which can be obtained from the GV with the <code>GvCV</code> macro.</p> <pre><code class="plaintext">GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)</code></pre> </dd> <dt id="gv_fetchmethod"><a class="permalink" href="#gv_fetchmethod">#</a>gv_fetchmethod</dt> <dd> <p>See <a href="/5.8.1/gv_fetchmethod_autoload">gv_fetchmethod_autoload</a>.</p> <pre><code class="plaintext">GV* gv_fetchmethod(HV* stash, const char* name)</code></pre> </dd> <dt id="gv_fetchmethod_autoload"><a class="permalink" href="#gv_fetchmethod_autoload">#</a>gv_fetchmethod_autoload</dt> <dd> <p>Returns the glob which contains the subroutine to call to invoke the method on the <code>stash</code>. In fact in the presence of autoloading this may be the glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is already setup.</p> <p>The third parameter of <code>gv_fetchmethod_autoload</code> determines whether AUTOLOAD lookup is performed if the given method is not present: non-zero means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. Calling <code>gv_fetchmethod</code> is equivalent to calling <code>gv_fetchmethod_autoload</code> with a non-zero <code>autoload</code> parameter.</p> <p>These functions grant <code>"SUPER"</code> token as a prefix of the method name. Note that if you want to keep the returned glob for a long time, you need to check for it being "AUTOLOAD", since at the later time the call may load a different subroutine due to $AUTOLOAD changing its value. Use the glob created via a side effect to do this.</p> <p>These functions have the same side-effects and as <code>gv_fetchmeth</code> with <code>level==0</code>. <code>name</code> should be writable if contains <code>':'</code> or <code>' ''</code>. The warning against passing the GV returned by <code>gv_fetchmeth</code> to <code>call_sv</code> apply equally to these functions.</p> <pre><code class="plaintext">GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)</code></pre> </dd> <dt id="gv_fetchmeth_autoload"><a class="permalink" href="#gv_fetchmeth_autoload">#</a>gv_fetchmeth_autoload</dt> <dd> <p>Same as gv_fetchmeth(), but looks for autoloaded subroutines too. Returns a glob for the subroutine.</p> <p>For an autoloaded subroutine without a GV, will create a GV even if <code>level < 0</code>. For an autoloaded subroutine without a stub, GvCV() of the result may be zero.</p> <pre><code class="plaintext">GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)</code></pre> </dd> <dt id="gv_stashpv"><a class="permalink" href="#gv_stashpv">#</a>gv_stashpv</dt> <dd> <p>Returns a pointer to the stash for a specified package. <code>name</code> should be a valid UTF-8 string. If <code>create</code> is set then the package will be created if it does not already exist. If <code>create</code> is not set and the package does not exist then NULL is returned.</p> <pre><code class="plaintext">HV* gv_stashpv(const char* name, I32 create)</code></pre> </dd> <dt id="gv_stashsv"><a class="permalink" href="#gv_stashsv">#</a>gv_stashsv</dt> <dd> <p>Returns a pointer to the stash for a specified package, which must be a valid UTF-8 string. See <code>gv_stashpv</code>.</p> <pre><code class="plaintext">HV* gv_stashsv(SV* sv, I32 create)</code></pre> </dd> </dl> <h1 id="Handy-Values"><a class="permalink" href="#Handy-Values">#</a><a id="Handy"></a>Handy Values</h1> <dl> <dt id="HEf_SVKEY"><a class="permalink" href="#HEf_SVKEY">#</a>HEf_SVKEY</dt> <dd> <p>This flag, used in the length slot of hash entries and magic structures, specifies the structure contains an <code>SV*</code> pointer where a <code>char*</code> pointer is to be expected. (For information only--not to be used).</p> </dd> <dt id="Nullch"><a class="permalink" href="#Nullch">#</a>Nullch</dt> <dd> <p>Null character pointer.</p> </dd> <dt id="Nullsv"><a class="permalink" href="#Nullsv">#</a>Nullsv</dt> <dd> <p>Null SV pointer.</p> </dd> </dl> <h1 id="Hash-Manipulation-Functions"><a class="permalink" href="#Hash-Manipulation-Functions">#</a><a id="Hash"></a>Hash Manipulation Functions</h1> <dl> <dt id="get_hv"><a class="permalink" href="#get_hv">#</a>get_hv</dt> <dd> <p>Returns the HV of the specified Perl hash. If <code>create</code> is set and the Perl variable does not exist then it will be created. If <code>create</code> is not set and the variable does not exist then NULL is returned.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">HV* get_hv(const char* name, I32 create)</code></pre> </dd> <dt id="HeHASH"><a class="permalink" href="#HeHASH">#</a>HeHASH</dt> <dd> <p>Returns the computed hash stored in the hash entry.</p> <pre><code class="plaintext">U32 HeHASH(HE* he)</code></pre> </dd> <dt id="HeKEY"><a class="permalink" href="#HeKEY">#</a>HeKEY</dt> <dd> <p>Returns the actual pointer stored in the key slot of the hash entry. The pointer may be either <code>char*</code> or <code>SV*</code>, depending on the value of <code>HeKLEN()</code>. Can be assigned to. The <code>HePV()</code> or <code>HeSVKEY()</code> macros are usually preferable for finding the value of a key.</p> <pre><code class="plaintext">void* HeKEY(HE* he)</code></pre> </dd> <dt id="HeKLEN"><a class="permalink" href="#HeKLEN">#</a>HeKLEN</dt> <dd> <p>If this is negative, and amounts to <code>HEf_SVKEY</code>, it indicates the entry holds an <code>SV*</code> key. Otherwise, holds the actual length of the key. Can be assigned to. The <code>HePV()</code> macro is usually preferable for finding key lengths.</p> <pre><code class="plaintext">STRLEN HeKLEN(HE* he)</code></pre> </dd> <dt id="HePV"><a class="permalink" href="#HePV">#</a>HePV</dt> <dd> <p>Returns the key slot of the hash entry as a <code>char*</code> value, doing any necessary dereferencing of possibly <code>SV*</code> keys. The length of the string is placed in <code>len</code> (this is a macro, so do <i>not</i> use <code>&len</code>). If you do not care about what the length of the key is, you may use the global variable <code>PL_na</code>, though this is rather less efficient than using a local variable. Remember though, that hash keys in perl are free to contain embedded nulls, so using <code>strlen()</code> or similar is not a good way to find the length of hash keys. This is very similar to the <code>SvPV()</code> macro described elsewhere in this document.</p> <pre><code class="plaintext">char* HePV(HE* he, STRLEN len)</code></pre> </dd> <dt id="HeSVKEY"><a class="permalink" href="#HeSVKEY">#</a>HeSVKEY</dt> <dd> <p>Returns the key as an <code>SV*</code>, or <code>Nullsv</code> if the hash entry does not contain an <code>SV*</code> key.</p> <pre><code class="plaintext">SV* HeSVKEY(HE* he)</code></pre> </dd> <dt id="HeSVKEY_force"><a class="permalink" href="#HeSVKEY_force">#</a>HeSVKEY_force</dt> <dd> <p>Returns the key as an <code>SV*</code>. Will create and return a temporary mortal <code>SV*</code> if the hash entry contains only a <code>char*</code> key.</p> <pre><code class="plaintext">SV* HeSVKEY_force(HE* he)</code></pre> </dd> <dt id="HeSVKEY_set"><a class="permalink" href="#HeSVKEY_set">#</a>HeSVKEY_set</dt> <dd> <p>Sets the key to a given <code>SV*</code>, taking care to set the appropriate flags to indicate the presence of an <code>SV*</code> key, and returns the same <code>SV*</code>.</p> <pre><code class="plaintext">SV* HeSVKEY_set(HE* he, SV* sv)</code></pre> </dd> <dt id="HeVAL"><a class="permalink" href="#HeVAL">#</a>HeVAL</dt> <dd> <p>Returns the value slot (type <code>SV*</code>) stored in the hash entry.</p> <pre><code class="plaintext">SV* HeVAL(HE* he)</code></pre> </dd> <dt id="HvNAME"><a class="permalink" href="#HvNAME">#</a>HvNAME</dt> <dd> <p>Returns the package name of a stash. See <code>SvSTASH</code>, <code>CvSTASH</code>.</p> <pre><code class="plaintext">char* HvNAME(HV* stash)</code></pre> </dd> <dt id="hv_clear"><a class="permalink" href="#hv_clear">#</a>hv_clear</dt> <dd> <p>Clears a hash, making it empty.</p> <pre><code class="plaintext">void hv_clear(HV* tb)</code></pre> </dd> <dt id="hv_delete"><a class="permalink" href="#hv_delete">#</a>hv_delete</dt> <dd> <p>Deletes a key/value pair in the hash. The value SV is removed from the hash and returned to the caller. The <code>klen</code> is the length of the key. The <code>flags</code> value will normally be zero; if set to G_DISCARD then NULL will be returned.</p> <pre><code class="plaintext">SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)</code></pre> </dd> <dt id="hv_delete_ent"><a class="permalink" href="#hv_delete_ent">#</a>hv_delete_ent</dt> <dd> <p>Deletes a key/value pair in the hash. The value SV is removed from the hash and returned to the caller. The <code>flags</code> value will normally be zero; if set to G_DISCARD then NULL will be returned. <code>hash</code> can be a valid precomputed hash value, or 0 to ask for it to be computed.</p> <pre><code class="plaintext">SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)</code></pre> </dd> <dt id="hv_exists"><a class="permalink" href="#hv_exists">#</a>hv_exists</dt> <dd> <p>Returns a boolean indicating whether the specified hash key exists. The <code>klen</code> is the length of the key.</p> <pre><code class="plaintext">bool hv_exists(HV* tb, const char* key, I32 klen)</code></pre> </dd> <dt id="hv_exists_ent"><a class="permalink" href="#hv_exists_ent">#</a>hv_exists_ent</dt> <dd> <p>Returns a boolean indicating whether the specified hash key exists. <code>hash</code> can be a valid precomputed hash value, or 0 to ask for it to be computed.</p> <pre><code class="plaintext">bool hv_exists_ent(HV* tb, SV* key, U32 hash)</code></pre> </dd> <dt id="hv_fetch"><a class="permalink" href="#hv_fetch">#</a>hv_fetch</dt> <dd> <p>Returns the SV which corresponds to the specified key in the hash. The <code>klen</code> is the length of the key. If <code>lval</code> is set then the fetch will be part of a store. Check that the return value is non-null before dereferencing it to an <code>SV*</code>.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied hashes.</p> <pre><code class="plaintext">SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)</code></pre> </dd> <dt id="hv_fetch_ent"><a class="permalink" href="#hv_fetch_ent">#</a>hv_fetch_ent</dt> <dd> <p>Returns the hash entry which corresponds to the specified key in the hash. <code>hash</code> must be a valid precomputed hash number for the given <code>key</code>, or 0 if you want the function to compute it. IF <code>lval</code> is set then the fetch will be part of a store. Make sure the return value is non-null before accessing it. The return value when <code>tb</code> is a tied hash is a pointer to a static location, so be sure to make a copy of the structure if you need to store it somewhere.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied hashes.</p> <pre><code class="plaintext">HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)</code></pre> </dd> <dt id="hv_iterinit"><a class="permalink" href="#hv_iterinit">#</a>hv_iterinit</dt> <dd> <p>Prepares a starting point to traverse a hash table. Returns the number of keys in the hash (i.e. the same as <code>HvKEYS(tb)</code>). The return value is currently only meaningful for hashes without tie magic.</p> <p>NOTE: Before version 5.004_65, <code>hv_iterinit</code> used to return the number of hash buckets that happen to be in use. If you still need that esoteric value, you can get it through the macro <code>HvFILL(tb)</code>.</p> <pre><code class="plaintext">I32 hv_iterinit(HV* tb)</code></pre> </dd> <dt id="hv_iterkey"><a class="permalink" href="#hv_iterkey">#</a>hv_iterkey</dt> <dd> <p>Returns the key from the current position of the hash iterator. See <code>hv_iterinit</code>.</p> <pre><code class="plaintext">char* hv_iterkey(HE* entry, I32* retlen)</code></pre> </dd> <dt id="hv_iterkeysv"><a class="permalink" href="#hv_iterkeysv">#</a>hv_iterkeysv</dt> <dd> <p>Returns the key as an <code>SV*</code> from the current position of the hash iterator. The return value will always be a mortal copy of the key. Also see <code>hv_iterinit</code>.</p> <pre><code class="plaintext">SV* hv_iterkeysv(HE* entry)</code></pre> </dd> <dt id="hv_iternext"><a class="permalink" href="#hv_iternext">#</a>hv_iternext</dt> <dd> <p>Returns entries from a hash iterator. See <code>hv_iterinit</code>.</p> <p>You may call <code>hv_delete</code> or <code>hv_delete_ent</code> on the hash entry that the iterator currently points to, without losing your place or invalidating your iterator. Note that in this case the current entry is deleted from the hash with your iterator holding the last reference to it. Your iterator is flagged to free the entry on the next call to <code>hv_iternext</code>, so you must not discard your iterator immediately else the entry will leak - call <code>hv_iternext</code> to trigger the resource deallocation.</p> <pre><code class="plaintext">HE* hv_iternext(HV* tb)</code></pre> </dd> <dt id="hv_iternextsv"><a class="permalink" href="#hv_iternextsv">#</a>hv_iternextsv</dt> <dd> <p>Performs an <code>hv_iternext</code>, <code>hv_iterkey</code>, and <code>hv_iterval</code> in one operation.</p> <pre><code class="plaintext">SV* hv_iternextsv(HV* hv, char** key, I32* retlen)</code></pre> </dd> <dt id="hv_iternext_flags"><a class="permalink" href="#hv_iternext_flags">#</a>hv_iternext_flags</dt> <dd> <p>Returns entries from a hash iterator. See <code>hv_iterinit</code> and <code>hv_iternext</code>. The <code>flags</code> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is set the placeholders keys (for restricted hashes) will be returned in addition to normal keys. By default placeholders are automatically skipped over. Currently a placeholder is implemented with a value that is <code>&Perl_sv_placeholder</code>. Note that the implementation of placeholders and restricted hashes may change, and the implementation currently is insufficiently abstracted for any change to be tidy.</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">HE* hv_iternext_flags(HV* tb, I32 flags)</code></pre> </dd> <dt id="hv_iterval"><a class="permalink" href="#hv_iterval">#</a>hv_iterval</dt> <dd> <p>Returns the value from the current position of the hash iterator. See <code>hv_iterkey</code>.</p> <pre><code class="plaintext">SV* hv_iterval(HV* tb, HE* entry)</code></pre> </dd> <dt id="hv_magic"><a class="permalink" href="#hv_magic">#</a>hv_magic</dt> <dd> <p>Adds magic to a hash. See <code>sv_magic</code>.</p> <pre><code class="plaintext">void hv_magic(HV* hv, GV* gv, int how)</code></pre> </dd> <dt id="hv_store"><a class="permalink" href="#hv_store">#</a>hv_store</dt> <dd> <p>Stores an SV in a hash. The hash key is specified as <code>key</code> and <code>klen</code> is the length of the key. The <code>hash</code> parameter is the precomputed hash value; if it is zero then Perl will compute it. The return value will be NULL if the operation failed or if the value did not need to be actually stored within the hash (as in the case of tied hashes). Otherwise it can be dereferenced to get the original <code>SV*</code>. Note that the caller is responsible for suitably incrementing the reference count of <code>val</code> before the call, and decrementing it if the function returned NULL. Effectively a successful hv_store takes ownership of one reference to <code>val</code>. This is usually what you want; a newly created SV has a reference count of one, so if all your code does is create SVs then store them in a hash, hv_store will own the only reference to the new SV, and your code doesn't need to do anything further to tidy up. hv_store is not implemented as a call to hv_store_ent, and does not create a temporary SV for the key, so if your key data is not already in SV form then use hv_store in preference to hv_store_ent.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied hashes.</p> <pre><code class="plaintext">SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)</code></pre> </dd> <dt id="hv_store_ent"><a class="permalink" href="#hv_store_ent">#</a>hv_store_ent</dt> <dd> <p>Stores <code>val</code> in a hash. The hash key is specified as <code>key</code>. The <code>hash</code> parameter is the precomputed hash value; if it is zero then Perl will compute it. The return value is the new hash entry so created. It will be NULL if the operation failed or if the value did not need to be actually stored within the hash (as in the case of tied hashes). Otherwise the contents of the return value can be accessed using the <code>He?</code> macros described here. Note that the caller is responsible for suitably incrementing the reference count of <code>val</code> before the call, and decrementing it if the function returned NULL. Effectively a successful hv_store_ent takes ownership of one reference to <code>val</code>. This is usually what you want; a newly created SV has a reference count of one, so if all your code does is create SVs then store them in a hash, hv_store will own the only reference to the new SV, and your code doesn't need to do anything further to tidy up. Note that hv_store_ent only reads the <code>key</code>; unlike <code>val</code> it does not take ownership of it, so maintaining the correct reference count on <code>key</code> is entirely the caller's responsibility. hv_store is not implemented as a call to hv_store_ent, and does not create a temporary SV for the key, so if your key data is not already in SV form then use hv_store in preference to hv_store_ent.</p> <p>See <a href="/5.8.1/perlguts#Understanding-the-Magic-of-Tied-Hashes-and-Arrays">"Understanding the Magic of Tied Hashes and Arrays" in perlguts</a> for more information on how to use this function on tied hashes.</p> <pre><code class="plaintext">HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)</code></pre> </dd> <dt id="hv_undef"><a class="permalink" href="#hv_undef">#</a>hv_undef</dt> <dd> <p>Undefines the hash.</p> <pre><code class="plaintext">void hv_undef(HV* tb)</code></pre> </dd> <dt id="newHV"><a class="permalink" href="#newHV">#</a>newHV</dt> <dd> <p>Creates a new HV. The reference count is set to 1.</p> <pre><code class="plaintext">HV* newHV()</code></pre> </dd> <dt id="Nullhv"><a class="permalink" href="#Nullhv">#</a>Nullhv</dt> <dd> <p>Null HV pointer.</p> </dd> </dl> <h1 id="Magical-Functions"><a class="permalink" href="#Magical-Functions">#</a><a id="Magical"></a>Magical Functions</h1> <dl> <dt id="mg_clear"><a class="permalink" href="#mg_clear">#</a>mg_clear</dt> <dd> <p>Clear something magical that the SV represents. See <code>sv_magic</code>.</p> <pre><code class="plaintext">int mg_clear(SV* sv)</code></pre> </dd> <dt id="mg_copy"><a class="permalink" href="#mg_copy">#</a>mg_copy</dt> <dd> <p>Copies the magic from one SV to another. See <code>sv_magic</code>.</p> <pre><code class="plaintext">int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)</code></pre> </dd> <dt id="mg_find"><a class="permalink" href="#mg_find">#</a>mg_find</dt> <dd> <p>Finds the magic pointer for type matching the SV. See <code>sv_magic</code>.</p> <pre><code class="plaintext">MAGIC* mg_find(SV* sv, int type)</code></pre> </dd> <dt id="mg_free"><a class="permalink" href="#mg_free">#</a>mg_free</dt> <dd> <p>Free any magic storage used by the SV. See <code>sv_magic</code>.</p> <pre><code class="plaintext">int mg_free(SV* sv)</code></pre> </dd> <dt id="mg_get"><a class="permalink" href="#mg_get">#</a>mg_get</dt> <dd> <p>Do magic after a value is retrieved from the SV. See <code>sv_magic</code>.</p> <pre><code class="plaintext">int mg_get(SV* sv)</code></pre> </dd> <dt id="mg_length"><a class="permalink" href="#mg_length">#</a>mg_length</dt> <dd> <p>Report on the SV's length. See <code>sv_magic</code>.</p> <pre><code class="plaintext">U32 mg_length(SV* sv)</code></pre> </dd> <dt id="mg_magical"><a class="permalink" href="#mg_magical">#</a>mg_magical</dt> <dd> <p>Turns on the magical status of an SV. See <code>sv_magic</code>.</p> <pre><code class="plaintext">void mg_magical(SV* sv)</code></pre> </dd> <dt id="mg_set"><a class="permalink" href="#mg_set">#</a>mg_set</dt> <dd> <p>Do magic after a value is assigned to the SV. See <code>sv_magic</code>.</p> <pre><code class="plaintext">int mg_set(SV* sv)</code></pre> </dd> <dt id="SvGETMAGIC"><a class="permalink" href="#SvGETMAGIC">#</a>SvGETMAGIC</dt> <dd> <p>Invokes <code>mg_get</code> on an SV if it has 'get' magic. This macro evaluates its argument more than once.</p> <pre><code class="plaintext">void SvGETMAGIC(SV* sv)</code></pre> </dd> <dt id="SvLOCK"><a class="permalink" href="#SvLOCK">#</a>SvLOCK</dt> <dd> <p>Arranges for a mutual exclusion lock to be obtained on sv if a suitable module has been loaded.</p> <pre><code class="plaintext">void SvLOCK(SV* sv)</code></pre> </dd> <dt id="SvSETMAGIC"><a class="permalink" href="#SvSETMAGIC">#</a>SvSETMAGIC</dt> <dd> <p>Invokes <code>mg_set</code> on an SV if it has 'set' magic. This macro evaluates its argument more than once.</p> <pre><code class="plaintext">void SvSETMAGIC(SV* sv)</code></pre> </dd> <dt id="SvSetMagicSV"><a class="permalink" href="#SvSetMagicSV">#</a>SvSetMagicSV</dt> <dd> <p>Like <code>SvSetSV</code>, but does any set magic required afterwards.</p> <pre><code class="plaintext">void SvSetMagicSV(SV* dsb, SV* ssv)</code></pre> </dd> <dt id="SvSetMagicSV_nosteal"><a class="permalink" href="#SvSetMagicSV_nosteal">#</a>SvSetMagicSV_nosteal</dt> <dd> <p>Like <code>SvSetMagicSV</code>, but does any set magic required afterwards.</p> <pre><code class="plaintext">void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)</code></pre> </dd> <dt id="SvSetSV"><a class="permalink" href="#SvSetSV">#</a>SvSetSV</dt> <dd> <p>Calls <code>sv_setsv</code> if dsv is not the same as ssv. May evaluate arguments more than once.</p> <pre><code class="plaintext">void SvSetSV(SV* dsb, SV* ssv)</code></pre> </dd> <dt id="SvSetSV_nosteal"><a class="permalink" href="#SvSetSV_nosteal">#</a>SvSetSV_nosteal</dt> <dd> <p>Calls a non-destructive version of <code>sv_setsv</code> if dsv is not the same as ssv. May evaluate arguments more than once.</p> <pre><code class="plaintext">void SvSetSV_nosteal(SV* dsv, SV* ssv)</code></pre> </dd> <dt id="SvSHARE"><a class="permalink" href="#SvSHARE">#</a>SvSHARE</dt> <dd> <p>Arranges for sv to be shared between threads if a suitable module has been loaded.</p> <pre><code class="plaintext">void SvSHARE(SV* sv)</code></pre> </dd> </dl> <h1 id="Memory-Management"><a class="permalink" href="#Memory-Management">#</a><a id="Memory"></a>Memory Management</h1> <dl> <dt id="Copy"><a class="permalink" href="#Copy">#</a>Copy</dt> <dd> <p>The XSUB-writer's interface to the C <code>memcpy</code> function. The <code>src</code> is the source, <code>dest</code> is the destination, <code>nitems</code> is the number of items, and <code>type</code> is the type. May fail on overlapping copies. See also <code>Move</code>.</p> <pre><code class="plaintext">void Copy(void* src, void* dest, int nitems, type)</code></pre> </dd> <dt id="Move"><a class="permalink" href="#Move">#</a>Move</dt> <dd> <p>The XSUB-writer's interface to the C <code>memmove</code> function. The <code>src</code> is the source, <code>dest</code> is the destination, <code>nitems</code> is the number of items, and <code>type</code> is the type. Can do overlapping moves. See also <code>Copy</code>.</p> <pre><code class="plaintext">void Move(void* src, void* dest, int nitems, type)</code></pre> </dd> <dt id="New"><a class="permalink" href="#New">#</a>New</dt> <dd> <p>The XSUB-writer's interface to the C <code>malloc</code> function.</p> <pre><code class="plaintext">void New(int id, void* ptr, int nitems, type)</code></pre> </dd> <dt id="Newc"><a class="permalink" href="#Newc">#</a>Newc</dt> <dd> <p>The XSUB-writer's interface to the C <code>malloc</code> function, with cast.</p> <pre><code class="plaintext">void Newc(int id, void* ptr, int nitems, type, cast)</code></pre> </dd> <dt id="NEWSV"><a class="permalink" href="#NEWSV">#</a>NEWSV</dt> <dd> <p>Creates a new SV. A non-zero <code>len</code> parameter indicates the number of bytes of preallocated string space the SV should have. An extra byte for a tailing NUL is also reserved. (SvPOK is not set for the SV even if string space is allocated.) The reference count for the new SV is set to 1. <code>id</code> is an integer id between 0 and 1299 (used to identify leaks).</p> <pre><code class="plaintext">SV* NEWSV(int id, STRLEN len)</code></pre> </dd> <dt id="Newz"><a class="permalink" href="#Newz">#</a>Newz</dt> <dd> <p>The XSUB-writer's interface to the C <code>malloc</code> function. The allocated memory is zeroed with <code>memzero</code>.</p> <pre><code class="plaintext">void Newz(int id, void* ptr, int nitems, type)</code></pre> </dd> <dt id="Poison"><a class="permalink" href="#Poison">#</a>Poison</dt> <dd> <p>Fill up memory with a pattern (byte 0xAB over and over again) that hopefully catches attempts to access uninitialized memory.</p> <pre><code class="plaintext">void Poison(void* dest, int nitems, type)</code></pre> </dd> <dt id="Renew"><a class="permalink" href="#Renew">#</a>Renew</dt> <dd> <p>The XSUB-writer's interface to the C <code>realloc</code> function.</p> <pre><code class="plaintext">void Renew(void* ptr, int nitems, type)</code></pre> </dd> <dt id="Renewc"><a class="permalink" href="#Renewc">#</a>Renewc</dt> <dd> <p>The XSUB-writer's interface to the C <code>realloc</code> function, with cast.</p> <pre><code class="plaintext">void Renewc(void* ptr, int nitems, type, cast)</code></pre> </dd> <dt id="Safefree"><a class="permalink" href="#Safefree">#</a>Safefree</dt> <dd> <p>The XSUB-writer's interface to the C <code>free</code> function.</p> <pre><code class="plaintext">void Safefree(void* ptr)</code></pre> </dd> <dt id="savepv"><a class="permalink" href="#savepv">#</a>savepv</dt> <dd> <p>Perl's version of <code>strdup()</code>. Returns a pointer to a newly allocated string which is a duplicate of <code>pv</code>. The size of the string is determined by <code>strlen()</code>. The memory allocated for the new string can be freed with the <code>Safefree()</code> function.</p> <pre><code class="plaintext">char* savepv(const char* pv)</code></pre> </dd> <dt id="savepvn"><a class="permalink" href="#savepvn">#</a>savepvn</dt> <dd> <p>Perl's version of what <code>strndup()</code> would be if it existed. Returns a pointer to a newly allocated string which is a duplicate of the first <code>len</code> bytes from <code>pv</code>. The memory allocated for the new string can be freed with the <code>Safefree()</code> function.</p> <pre><code class="plaintext">char* savepvn(const char* pv, I32 len)</code></pre> </dd> <dt id="savesharedpv"><a class="permalink" href="#savesharedpv">#</a>savesharedpv</dt> <dd> <p>A version of <code>savepv()</code> which allocates the duplicate string in memory which is shared between threads.</p> <pre><code class="plaintext">char* savesharedpv(const char* pv)</code></pre> </dd> <dt id="StructCopy"><a class="permalink" href="#StructCopy">#</a>StructCopy</dt> <dd> <p>This is an architecture-independent macro to copy one structure to another.</p> <pre><code class="plaintext">void StructCopy(type src, type dest, type)</code></pre> </dd> <dt id="Zero"><a class="permalink" href="#Zero">#</a>Zero</dt> <dd> <p>The XSUB-writer's interface to the C <code>memzero</code> function. The <code>dest</code> is the destination, <code>nitems</code> is the number of items, and <code>type</code> is the type.</p> <pre><code class="plaintext">void Zero(void* dest, int nitems, type)</code></pre> </dd> </dl> <h1 id="Miscellaneous-Functions"><a class="permalink" href="#Miscellaneous-Functions">#</a><a id="Miscellaneous"></a>Miscellaneous Functions</h1> <dl> <dt id="fbm_compile"><a class="permalink" href="#fbm_compile">#</a>fbm_compile</dt> <dd> <p>Analyses the string in order to make fast searches on it using fbm_instr() -- the Boyer-Moore algorithm.</p> <pre><code class="plaintext">void fbm_compile(SV* sv, U32 flags)</code></pre> </dd> <dt id="fbm_instr"><a class="permalink" href="#fbm_instr">#</a>fbm_instr</dt> <dd> <p>Returns the location of the SV in the string delimited by <code>str</code> and <code>strend</code>. It returns <code>Nullch</code> if the string can't be found. The <code>sv</code> does not have to be fbm_compiled, but the search will not be as fast then.</p> <pre><code class="plaintext">char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)</code></pre> </dd> <dt id="form"><a class="permalink" href="#form">#</a>form</dt> <dd> <p>Takes a sprintf-style format pattern and conventional (non-SV) arguments and returns the formatted string.</p> <pre><code class="plaintext">(char *) Perl_form(pTHX_ const char* pat, ...)</code></pre> <p>can be used any place a string (char *) is required:</p> <pre><code>char * s = Perl_form("%d.%d",major,minor);</code></pre> <p>Uses a single private buffer so if you want to format several strings you must explicitly copy the earlier strings away (and free the copies when you are done).</p> <pre><code class="plaintext">char* form(const char* pat, ...)</code></pre> </dd> <dt id="getcwd_sv"><a class="permalink" href="#getcwd_sv">#</a>getcwd_sv</dt> <dd> <p>Fill the sv with current working directory</p> <pre><code class="plaintext">int getcwd_sv(SV* sv)</code></pre> </dd> <dt id="strEQ"><a class="permalink" href="#strEQ">#</a>strEQ</dt> <dd> <p>Test two strings to see if they are equal. Returns true or false.</p> <pre><code class="plaintext">bool strEQ(char* s1, char* s2)</code></pre> </dd> <dt id="strGE"><a class="permalink" href="#strGE">#</a>strGE</dt> <dd> <p>Test two strings to see if the first, <code>s1</code>, is greater than or equal to the second, <code>s2</code>. Returns true or false.</p> <pre><code class="plaintext">bool strGE(char* s1, char* s2)</code></pre> </dd> <dt id="strGT"><a class="permalink" href="#strGT">#</a>strGT</dt> <dd> <p>Test two strings to see if the first, <code>s1</code>, is greater than the second, <code>s2</code>. Returns true or false.</p> <pre><code class="plaintext">bool strGT(char* s1, char* s2)</code></pre> </dd> <dt id="strLE"><a class="permalink" href="#strLE">#</a>strLE</dt> <dd> <p>Test two strings to see if the first, <code>s1</code>, is less than or equal to the second, <code>s2</code>. Returns true or false.</p> <pre><code class="plaintext">bool strLE(char* s1, char* s2)</code></pre> </dd> <dt id="strLT"><a class="permalink" href="#strLT">#</a>strLT</dt> <dd> <p>Test two strings to see if the first, <code>s1</code>, is less than the second, <code>s2</code>. Returns true or false.</p> <pre><code class="plaintext">bool strLT(char* s1, char* s2)</code></pre> </dd> <dt id="strNE"><a class="permalink" href="#strNE">#</a>strNE</dt> <dd> <p>Test two strings to see if they are different. Returns true or false.</p> <pre><code class="plaintext">bool strNE(char* s1, char* s2)</code></pre> </dd> <dt id="strnEQ"><a class="permalink" href="#strnEQ">#</a>strnEQ</dt> <dd> <p>Test two strings to see if they are equal. The <code>len</code> parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for <code>strncmp</code>).</p> <pre><code class="plaintext">bool strnEQ(char* s1, char* s2, STRLEN len)</code></pre> </dd> <dt id="strnNE"><a class="permalink" href="#strnNE">#</a>strnNE</dt> <dd> <p>Test two strings to see if they are different. The <code>len</code> parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for <code>strncmp</code>).</p> <pre><code class="plaintext">bool strnNE(char* s1, char* s2, STRLEN len)</code></pre> </dd> <dt id="sv_nolocking"><a class="permalink" href="#sv_nolocking">#</a>sv_nolocking</dt> <dd> <p>Dummy routine which "locks" an SV when there is no locking module present. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness.</p> <pre><code class="plaintext">void sv_nolocking(SV *)</code></pre> </dd> <dt id="sv_nosharing"><a class="permalink" href="#sv_nosharing">#</a>sv_nosharing</dt> <dd> <p>Dummy routine which "shares" an SV when there is no sharing module present. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness.</p> <pre><code class="plaintext">void sv_nosharing(SV *)</code></pre> </dd> <dt id="sv_nounlocking"><a class="permalink" href="#sv_nounlocking">#</a>sv_nounlocking</dt> <dd> <p>Dummy routine which "unlocks" an SV when there is no locking module present. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness.</p> <pre><code class="plaintext">void sv_nounlocking(SV *)</code></pre> </dd> </dl> <h1 id="Numeric-functions"><a class="permalink" href="#Numeric-functions">#</a><a id="Numeric"></a>Numeric functions</h1> <dl> <dt id="grok_bin"><a class="permalink" href="#grok_bin">#</a>grok_bin</dt> <dd> <p>converts a string representing a binary number to numeric form.</p> <p>On entry <i>start</i> and <i>*len</i> give the string to scan, <i>*flags</i> gives conversion flags, and <i>result</i> should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first invalid character. On return <i>*len</i> is set to the length scanned string, and <i>*flags</i> gives output flags.</p> <p>If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to <i>*result</i>. If the value is > UV_MAX <code>grok_bin</code> returns UV_MAX, sets <code>PERL_SCAN_GREATER_THAN_UV_MAX</code> in the output flags, and writes the value to <i>*result</i> (or the value is discarded if <i>result</i> is NULL).</p> <p>The hex number may optionally be prefixed with "0b" or "b" unless <code>PERL_SCAN_DISALLOW_PREFIX</code> is set in <i>*flags</i> on entry. If <code>PERL_SCAN_ALLOW_UNDERSCORES</code> is set in <i>*flags</i> then the binary number may use '_' characters to separate digits.</p> <pre><code class="plaintext">UV grok_bin(char* start, STRLEN* len, I32* flags, NV *result)</code></pre> </dd> <dt id="grok_hex"><a class="permalink" href="#grok_hex">#</a>grok_hex</dt> <dd> <p>converts a string representing a hex number to numeric form.</p> <p>On entry <i>start</i> and <i>*len</i> give the string to scan, <i>*flags</i> gives conversion flags, and <i>result</i> should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first non-hex-digit character. On return <i>*len</i> is set to the length scanned string, and <i>*flags</i> gives output flags.</p> <p>If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to <i>*result</i>. If the value is > UV_MAX <code>grok_hex</code> returns UV_MAX, sets <code>PERL_SCAN_GREATER_THAN_UV_MAX</code> in the output flags, and writes the value to <i>*result</i> (or the value is discarded if <i>result</i> is NULL).</p> <p>The hex number may optionally be prefixed with "0x" or "x" unless <code>PERL_SCAN_DISALLOW_PREFIX</code> is set in <i>*flags</i> on entry. If <code>PERL_SCAN_ALLOW_UNDERSCORES</code> is set in <i>*flags</i> then the hex number may use '_' characters to separate digits.</p> <pre><code class="plaintext">UV grok_hex(char* start, STRLEN* len, I32* flags, NV *result)</code></pre> </dd> <dt id="grok_number"><a class="permalink" href="#grok_number">#</a>grok_number</dt> <dd> <p>Recognise (or not) a number. The type of the number is returned (0 if unrecognised), otherwise it is a bit-ORed combination of IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT, IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h).</p> <p>If the value of the number can fit an in UV, it is returned in the *valuep IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV will never be set unless *valuep is valid, but *valuep may have been assigned to during processing even though IS_NUMBER_IN_UV is not set on return. If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when valuep is non-NULL, but no actual assignment (or SEGV) will occur.</p> <p>IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were seen (in which case *valuep gives the true value truncated to an integer), and IS_NUMBER_NEG if the number is negative (in which case *valuep holds the absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the number is larger than a UV.</p> <pre><code class="plaintext">int grok_number(const char *pv, STRLEN len, UV *valuep)</code></pre> </dd> <dt id="grok_numeric_radix"><a class="permalink" href="#grok_numeric_radix">#</a>grok_numeric_radix</dt> <dd> <p>Scan and skip for a numeric decimal separator (radix).</p> <pre><code class="plaintext">bool grok_numeric_radix(const char **sp, const char *send)</code></pre> </dd> <dt id="grok_oct"><a class="permalink" href="#grok_oct">#</a>grok_oct</dt> <dd> <pre><code class="plaintext">UV grok_oct(char* start, STRLEN* len, I32* flags, NV *result)</code></pre> </dd> <dt id="scan_bin"><a class="permalink" href="#scan_bin">#</a>scan_bin</dt> <dd> <p>For backwards compatibility. Use <code>grok_bin</code> instead.</p> <pre><code class="plaintext">NV scan_bin(char* start, STRLEN len, STRLEN* retlen)</code></pre> </dd> <dt id="scan_hex"><a class="permalink" href="#scan_hex">#</a>scan_hex</dt> <dd> <p>For backwards compatibility. Use <code>grok_hex</code> instead.</p> <pre><code class="plaintext">NV scan_hex(char* start, STRLEN len, STRLEN* retlen)</code></pre> </dd> <dt id="scan_oct"><a class="permalink" href="#scan_oct">#</a>scan_oct</dt> <dd> <p>For backwards compatibility. Use <code>grok_oct</code> instead.</p> <pre><code class="plaintext">NV scan_oct(char* start, STRLEN len, STRLEN* retlen)</code></pre> </dd> </dl> <h1 id="Optree-Manipulation-Functions"><a class="permalink" href="#Optree-Manipulation-Functions">#</a><a id="Optree"></a>Optree Manipulation Functions</h1> <dl> <dt id="cv_const_sv"><a class="permalink" href="#cv_const_sv">#</a>cv_const_sv</dt> <dd> <p>If <code>cv</code> is a constant sub eligible for inlining. returns the constant value returned by the sub. Otherwise, returns NULL.</p> <p>Constant subs can be created with <code>newCONSTSUB</code> or as described in <a href="/5.8.1/perlsub#Constant-Functions">"Constant Functions" in perlsub</a>.</p> <pre><code class="plaintext">SV* cv_const_sv(CV* cv)</code></pre> </dd> <dt id="newCONSTSUB"><a class="permalink" href="#newCONSTSUB">#</a>newCONSTSUB</dt> <dd> <p>Creates a constant sub equivalent to Perl <code>sub FOO () { 123 }</code> which is eligible for inlining at compile-time.</p> <pre><code class="plaintext">CV* newCONSTSUB(HV* stash, char* name, SV* sv)</code></pre> </dd> <dt id="newXS"><a class="permalink" href="#newXS">#</a>newXS</dt> <dd> <p>Used by <code>xsubpp</code> to hook up XSUBs as Perl subs.</p> </dd> </dl> <h1 id="Pad-Data-Structures"><a class="permalink" href="#Pad-Data-Structures">#</a><a id="Pad"></a>Pad Data Structures</h1> <dl> <dt id="pad_sv"><a class="permalink" href="#pad_sv">#</a>pad_sv</dt> <dd> <p>Get the value at offset po in the current pad. Use macro PAD_SV instead of calling this function directly.</p> <pre><code class="plaintext">SV* pad_sv(PADOFFSET po)</code></pre> </dd> </dl> <h1 id="Stack-Manipulation-Macros"><a class="permalink" href="#Stack-Manipulation-Macros">#</a><a id="Stack"></a>Stack Manipulation Macros</h1> <dl> <dt id="dMARK"><a class="permalink" href="#dMARK">#</a>dMARK</dt> <dd> <p>Declare a stack marker variable, <code>mark</code>, for the XSUB. See <code>MARK</code> and <code>dORIGMARK</code>.</p> <pre><code>dMARK;</code></pre> </dd> <dt id="dORIGMARK"><a class="permalink" href="#dORIGMARK">#</a>dORIGMARK</dt> <dd> <p>Saves the original stack mark for the XSUB. See <code>ORIGMARK</code>.</p> <pre><code>dORIGMARK;</code></pre> </dd> <dt id="dSP"><a class="permalink" href="#dSP">#</a>dSP</dt> <dd> <p>Declares a local copy of perl's stack pointer for the XSUB, available via the <code>SP</code> macro. See <code>SP</code>.</p> <pre><code>dSP;</code></pre> </dd> <dt id="EXTEND"><a class="permalink" href="#EXTEND">#</a>EXTEND</dt> <dd> <p>Used to extend the argument stack for an XSUB's return values. Once used, guarantees that there is room for at least <code>nitems</code> to be pushed onto the stack.</p> <pre><code class="plaintext">void EXTEND(SP, int nitems)</code></pre> </dd> <dt id="MARK"><a class="permalink" href="#MARK">#</a>MARK</dt> <dd> <p>Stack marker variable for the XSUB. See <code>dMARK</code>.</p> </dd> <dt id="ORIGMARK"><a class="permalink" href="#ORIGMARK">#</a>ORIGMARK</dt> <dd> <p>The original stack mark for the XSUB. See <code>dORIGMARK</code>.</p> </dd> <dt id="POPi"><a class="permalink" href="#POPi">#</a>POPi</dt> <dd> <p>Pops an integer off the stack.</p> <pre><code class="plaintext">IV POPi</code></pre> </dd> <dt id="POPl"><a class="permalink" href="#POPl">#</a>POPl</dt> <dd> <p>Pops a long off the stack.</p> <pre><code class="plaintext">long POPl</code></pre> </dd> <dt id="POPn"><a class="permalink" href="#POPn">#</a>POPn</dt> <dd> <p>Pops a double off the stack.</p> <pre><code class="plaintext">NV POPn</code></pre> </dd> <dt id="POPp"><a class="permalink" href="#POPp">#</a>POPp</dt> <dd> <p>Pops a string off the stack. Deprecated. New code should provide a STRLEN n_a and use POPpx.</p> <pre><code class="plaintext">char* POPp</code></pre> </dd> <dt id="POPpbytex"><a class="permalink" href="#POPpbytex">#</a>POPpbytex</dt> <dd> <p>Pops a string off the stack which must consist of bytes i.e. characters < 256. Requires a variable STRLEN n_a in scope.</p> <pre><code class="plaintext">char* POPpbytex</code></pre> </dd> <dt id="POPpx"><a class="permalink" href="#POPpx">#</a>POPpx</dt> <dd> <p>Pops a string off the stack. Requires a variable STRLEN n_a in scope.</p> <pre><code class="plaintext">char* POPpx</code></pre> </dd> <dt id="POPs"><a class="permalink" href="#POPs">#</a>POPs</dt> <dd> <p>Pops an SV off the stack.</p> <pre><code class="plaintext">SV* POPs</code></pre> </dd> <dt id="PUSHi"><a class="permalink" href="#PUSHi">#</a>PUSHi</dt> <dd> <p>Push an integer onto the stack. The stack must have room for this element. Handles 'set' magic. See <code>XPUSHi</code>.</p> <pre><code class="plaintext">void PUSHi(IV iv)</code></pre> </dd> <dt id="PUSHMARK"><a class="permalink" href="#PUSHMARK">#</a>PUSHMARK</dt> <dd> <p>Opening bracket for arguments on a callback. See <code>PUTBACK</code> and <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>PUSHMARK;</code></pre> </dd> <dt id="PUSHn"><a class="permalink" href="#PUSHn">#</a>PUSHn</dt> <dd> <p>Push a double onto the stack. The stack must have room for this element. Handles 'set' magic. See <code>XPUSHn</code>.</p> <pre><code class="plaintext">void PUSHn(NV nv)</code></pre> </dd> <dt id="PUSHp"><a class="permalink" href="#PUSHp">#</a>PUSHp</dt> <dd> <p>Push a string onto the stack. The stack must have room for this element. The <code>len</code> indicates the length of the string. Handles 'set' magic. See <code>XPUSHp</code>.</p> <pre><code class="plaintext">void PUSHp(char* str, STRLEN len)</code></pre> </dd> <dt id="PUSHs"><a class="permalink" href="#PUSHs">#</a>PUSHs</dt> <dd> <p>Push an SV onto the stack. The stack must have room for this element. Does not handle 'set' magic. See <code>XPUSHs</code>.</p> <pre><code class="plaintext">void PUSHs(SV* sv)</code></pre> </dd> <dt id="PUSHu"><a class="permalink" href="#PUSHu">#</a>PUSHu</dt> <dd> <p>Push an unsigned integer onto the stack. The stack must have room for this element. See <code>XPUSHu</code>.</p> <pre><code class="plaintext">void PUSHu(UV uv)</code></pre> </dd> <dt id="PUTBACK"><a class="permalink" href="#PUTBACK">#</a>PUTBACK</dt> <dd> <p>Closing bracket for XSUB arguments. This is usually handled by <code>xsubpp</code>. See <code>PUSHMARK</code> and <a href="/5.8.1/perlcall">perlcall</a> for other uses.</p> <pre><code>PUTBACK;</code></pre> </dd> <dt id="SP"><a class="permalink" href="#SP">#</a>SP</dt> <dd> <p>Stack pointer. This is usually handled by <code>xsubpp</code>. See <code>dSP</code> and <code>SPAGAIN</code>.</p> </dd> <dt id="SPAGAIN"><a class="permalink" href="#SPAGAIN">#</a>SPAGAIN</dt> <dd> <p>Refetch the stack pointer. Used after a callback. See <a href="/5.8.1/perlcall">perlcall</a>.</p> <pre><code>SPAGAIN;</code></pre> </dd> <dt id="XPUSHi"><a class="permalink" href="#XPUSHi">#</a>XPUSHi</dt> <dd> <p>Push an integer onto the stack, extending the stack if necessary. Handles 'set' magic. See <code>PUSHi</code>.</p> <pre><code class="plaintext">void XPUSHi(IV iv)</code></pre> </dd> <dt id="XPUSHn"><a class="permalink" href="#XPUSHn">#</a>XPUSHn</dt> <dd> <p>Push a double onto the stack, extending the stack if necessary. Handles 'set' magic. See <code>PUSHn</code>.</p> <pre><code class="plaintext">void XPUSHn(NV nv)</code></pre> </dd> <dt id="XPUSHp"><a class="permalink" href="#XPUSHp">#</a>XPUSHp</dt> <dd> <p>Push a string onto the stack, extending the stack if necessary. The <code>len</code> indicates the length of the string. Handles 'set' magic. See <code>PUSHp</code>.</p> <pre><code class="plaintext">void XPUSHp(char* str, STRLEN len)</code></pre> </dd> <dt id="XPUSHs"><a class="permalink" href="#XPUSHs">#</a>XPUSHs</dt> <dd> <p>Push an SV onto the stack, extending the stack if necessary. Does not handle 'set' magic. See <code>PUSHs</code>.</p> <pre><code class="plaintext">void XPUSHs(SV* sv)</code></pre> </dd> <dt id="XPUSHu"><a class="permalink" href="#XPUSHu">#</a>XPUSHu</dt> <dd> <p>Push an unsigned integer onto the stack, extending the stack if necessary. See <code>PUSHu</code>.</p> <pre><code class="plaintext">void XPUSHu(UV uv)</code></pre> </dd> <dt id="XSRETURN"><a class="permalink" href="#XSRETURN">#</a>XSRETURN</dt> <dd> <p>Return from XSUB, indicating number of items on the stack. This is usually handled by <code>xsubpp</code>.</p> <pre><code class="plaintext">void XSRETURN(int nitems)</code></pre> </dd> <dt id="XSRETURN_IV"><a class="permalink" href="#XSRETURN_IV">#</a>XSRETURN_IV</dt> <dd> <p>Return an integer from an XSUB immediately. Uses <code>XST_mIV</code>.</p> <pre><code class="plaintext">void XSRETURN_IV(IV iv)</code></pre> </dd> <dt id="XSRETURN_NO"><a class="permalink" href="#XSRETURN_NO">#</a>XSRETURN_NO</dt> <dd> <p>Return <code>&PL_sv_no</code> from an XSUB immediately. Uses <code>XST_mNO</code>.</p> <pre><code>XSRETURN_NO;</code></pre> </dd> <dt id="XSRETURN_NV"><a class="permalink" href="#XSRETURN_NV">#</a>XSRETURN_NV</dt> <dd> <p>Return a double from an XSUB immediately. Uses <code>XST_mNV</code>.</p> <pre><code class="plaintext">void XSRETURN_NV(NV nv)</code></pre> </dd> <dt id="XSRETURN_PV"><a class="permalink" href="#XSRETURN_PV">#</a>XSRETURN_PV</dt> <dd> <p>Return a copy of a string from an XSUB immediately. Uses <code>XST_mPV</code>.</p> <pre><code class="plaintext">void XSRETURN_PV(char* str)</code></pre> </dd> <dt id="XSRETURN_UNDEF"><a class="permalink" href="#XSRETURN_UNDEF">#</a>XSRETURN_UNDEF</dt> <dd> <p>Return <code>&PL_sv_undef</code> from an XSUB immediately. Uses <code>XST_mUNDEF</code>.</p> <pre><code>XSRETURN_UNDEF;</code></pre> </dd> <dt id="XSRETURN_UV"><a class="permalink" href="#XSRETURN_UV">#</a>XSRETURN_UV</dt> <dd> <p>Return an integer from an XSUB immediately. Uses <code>XST_mUV</code>.</p> <pre><code class="plaintext">void XSRETURN_UV(IV uv)</code></pre> </dd> <dt id="XSRETURN_YES"><a class="permalink" href="#XSRETURN_YES">#</a>XSRETURN_YES</dt> <dd> <p>Return <code>&PL_sv_yes</code> from an XSUB immediately. Uses <code>XST_mYES</code>.</p> <pre><code>XSRETURN_YES;</code></pre> </dd> <dt id="XST_mIV"><a class="permalink" href="#XST_mIV">#</a>XST_mIV</dt> <dd> <p>Place an integer into the specified position <code>pos</code> on the stack. The value is stored in a new mortal SV.</p> <pre><code class="plaintext">void XST_mIV(int pos, IV iv)</code></pre> </dd> <dt id="XST_mNO"><a class="permalink" href="#XST_mNO">#</a>XST_mNO</dt> <dd> <p>Place <code>&PL_sv_no</code> into the specified position <code>pos</code> on the stack.</p> <pre><code class="plaintext">void XST_mNO(int pos)</code></pre> </dd> <dt id="XST_mNV"><a class="permalink" href="#XST_mNV">#</a>XST_mNV</dt> <dd> <p>Place a double into the specified position <code>pos</code> on the stack. The value is stored in a new mortal SV.</p> <pre><code class="plaintext">void XST_mNV(int pos, NV nv)</code></pre> </dd> <dt id="XST_mPV"><a class="permalink" href="#XST_mPV">#</a>XST_mPV</dt> <dd> <p>Place a copy of a string into the specified position <code>pos</code> on the stack. The value is stored in a new mortal SV.</p> <pre><code class="plaintext">void XST_mPV(int pos, char* str)</code></pre> </dd> <dt id="XST_mUNDEF"><a class="permalink" href="#XST_mUNDEF">#</a>XST_mUNDEF</dt> <dd> <p>Place <code>&PL_sv_undef</code> into the specified position <code>pos</code> on the stack.</p> <pre><code class="plaintext">void XST_mUNDEF(int pos)</code></pre> </dd> <dt id="XST_mYES"><a class="permalink" href="#XST_mYES">#</a>XST_mYES</dt> <dd> <p>Place <code>&PL_sv_yes</code> into the specified position <code>pos</code> on the stack.</p> <pre><code class="plaintext">void XST_mYES(int pos)</code></pre> </dd> </dl> <h1 id="SV-Flags"><a class="permalink" href="#SV-Flags">#</a><a id="SV"></a>SV Flags</h1> <dl> <dt id="svtype"><a class="permalink" href="#svtype">#</a>svtype</dt> <dd> <p>An enum of flags for Perl types. These are found in the file <b>sv.h</b> in the <code>svtype</code> enum. Test these flags with the <code>SvTYPE</code> macro.</p> </dd> <dt id="SVt_IV"><a class="permalink" href="#SVt_IV">#</a>SVt_IV</dt> <dd> <p>Integer type flag for scalars. See <code>svtype</code>.</p> </dd> <dt id="SVt_NV"><a class="permalink" href="#SVt_NV">#</a>SVt_NV</dt> <dd> <p>Double type flag for scalars. See <code>svtype</code>.</p> </dd> <dt id="SVt_PV"><a class="permalink" href="#SVt_PV">#</a>SVt_PV</dt> <dd> <p>Pointer type flag for scalars. See <code>svtype</code>.</p> </dd> <dt id="SVt_PVAV"><a class="permalink" href="#SVt_PVAV">#</a>SVt_PVAV</dt> <dd> <p>Type flag for arrays. See <code>svtype</code>.</p> </dd> <dt id="SVt_PVCV"><a class="permalink" href="#SVt_PVCV">#</a>SVt_PVCV</dt> <dd> <p>Type flag for code refs. See <code>svtype</code>.</p> </dd> <dt id="SVt_PVHV"><a class="permalink" href="#SVt_PVHV">#</a>SVt_PVHV</dt> <dd> <p>Type flag for hashes. See <code>svtype</code>.</p> </dd> <dt id="SVt_PVMG"><a class="permalink" href="#SVt_PVMG">#</a>SVt_PVMG</dt> <dd> <p>Type flag for blessed scalars. See <code>svtype</code>.</p> </dd> </dl> <h1 id="SV-Manipulation-Functions"><a class="permalink" href="#SV-Manipulation-Functions">#</a><a id="SV1"></a>SV Manipulation Functions</h1> <dl> <dt id="get_sv"><a class="permalink" href="#get_sv">#</a>get_sv</dt> <dd> <p>Returns the SV of the specified Perl scalar. If <code>create</code> is set and the Perl variable does not exist then it will be created. If <code>create</code> is not set and the variable does not exist then NULL is returned.</p> <p>NOTE: the perl_ form of this function is deprecated.</p> <pre><code class="plaintext">SV* get_sv(const char* name, I32 create)</code></pre> </dd> <dt id="looks_like_number"><a class="permalink" href="#looks_like_number">#</a>looks_like_number</dt> <dd> <p>Test if the content of an SV looks like a number (or is a number). <code>Inf</code> and <code>Infinity</code> are treated as numbers (so will not issue a non-numeric warning), even if your atof() doesn't grok them.</p> <pre><code class="plaintext">I32 looks_like_number(SV* sv)</code></pre> </dd> <dt id="newRV_inc"><a class="permalink" href="#newRV_inc">#</a>newRV_inc</dt> <dd> <p>Creates an RV wrapper for an SV. The reference count for the original SV is incremented.</p> <pre><code class="plaintext">SV* newRV_inc(SV* sv)</code></pre> </dd> <dt id="newRV_noinc"><a class="permalink" href="#newRV_noinc">#</a>newRV_noinc</dt> <dd> <p>Creates an RV wrapper for an SV. The reference count for the original SV is <b>not</b> incremented.</p> <pre><code class="plaintext">SV* newRV_noinc(SV *sv)</code></pre> </dd> <dt id="newSV"><a class="permalink" href="#newSV">#</a>newSV</dt> <dd> <p>Create a new null SV, or if len > 0, create a new empty SVt_PV type SV with an initial PV allocation of len+1. Normally accessed via the <code>NEWSV</code> macro.</p> <pre><code class="plaintext">SV* newSV(STRLEN len)</code></pre> </dd> <dt id="newSViv"><a class="permalink" href="#newSViv">#</a>newSViv</dt> <dd> <p>Creates a new SV and copies an integer into it. The reference count for the SV is set to 1.</p> <pre><code class="plaintext">SV* newSViv(IV i)</code></pre> </dd> <dt id="newSVnv"><a class="permalink" href="#newSVnv">#</a>newSVnv</dt> <dd> <p>Creates a new SV and copies a floating point value into it. The reference count for the SV is set to 1.</p> <pre><code class="plaintext">SV* newSVnv(NV n)</code></pre> </dd> <dt id="newSVpv"><a class="permalink" href="#newSVpv">#</a>newSVpv</dt> <dd> <p>Creates a new SV and copies a string into it. The reference count for the SV is set to 1. If <code>len</code> is zero, Perl will compute the length using strlen(). For efficiency, consider using <code>newSVpvn</code> instead.</p> <pre><code class="plaintext">SV* newSVpv(const char* s, STRLEN len)</code></pre> </dd> <dt id="newSVpvf"><a class="permalink" href="#newSVpvf">#</a>newSVpvf</dt> <dd> <p>Creates a new SV and initializes it with the string formatted like <code>sprintf</code>.</p> <pre><code class="plaintext">SV* newSVpvf(const char* pat, ...)</code></pre> </dd> <dt id="newSVpvn"><a class="permalink" href="#newSVpvn">#</a>newSVpvn</dt> <dd> <p>Creates a new SV and copies a string into it. The reference count for the SV is set to 1. Note that if <code>len</code> is zero, Perl will create a zero length string. You are responsible for ensuring that the source string is at least <code>len</code> bytes long.</p> <pre><code class="plaintext">SV* newSVpvn(const char* s, STRLEN len)</code></pre> </dd> <dt id="newSVpvn_share"><a class="permalink" href="#newSVpvn_share">#</a>newSVpvn_share</dt> <dd> <p>Creates a new SV with its SvPVX pointing to a shared string in the string table. If the string does not already exist in the table, it is created first. Turns on READONLY and FAKE. The string's hash is stored in the UV slot of the SV; if the <code>hash</code> parameter is non-zero, that value is used; otherwise the hash is computed. The idea here is that as the string table is used for shared hash keys these strings will have SvPVX == HeKEY and hash lookup will avoid string compare.</p> <pre><code class="plaintext">SV* newSVpvn_share(const char* s, I32 len, U32 hash)</code></pre> </dd> <dt id="newSVrv"><a class="permalink" href="#newSVrv">#</a>newSVrv</dt> <dd> <p>Creates a new SV for the RV, <code>rv</code>, to point to. If <code>rv</code> is not an RV then it will be upgraded to one. If <code>classname</code> is non-null then the new SV will be blessed in the specified package. The new SV is returned and its reference count is 1.</p> <pre><code class="plaintext">SV* newSVrv(SV* rv, const char* classname)</code></pre> </dd> <dt id="newSVsv"><a class="permalink" href="#newSVsv">#</a>newSVsv</dt> <dd> <p>Creates a new SV which is an exact duplicate of the original SV. (Uses <code>sv_setsv</code>).</p> <pre><code class="plaintext">SV* newSVsv(SV* old)</code></pre> </dd> <dt id="newSVuv"><a class="permalink" href="#newSVuv">#</a>newSVuv</dt> <dd> <p>Creates a new SV and copies an unsigned integer into it. The reference count for the SV is set to 1.</p> <pre><code class="plaintext">SV* newSVuv(UV u)</code></pre> </dd> <dt id="SvCUR"><a class="permalink" href="#SvCUR">#</a>SvCUR</dt> <dd> <p>Returns the length of the string which is in the SV. See <code>SvLEN</code>.</p> <pre><code class="plaintext">STRLEN SvCUR(SV* sv)</code></pre> </dd> <dt id="SvCUR_set"><a class="permalink" href="#SvCUR_set">#</a>SvCUR_set</dt> <dd> <p>Set the length of the string which is in the SV. See <code>SvCUR</code>.</p> <pre><code class="plaintext">void SvCUR_set(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvEND"><a class="permalink" href="#SvEND">#</a>SvEND</dt> <dd> <p>Returns a pointer to the last character in the string which is in the SV. See <code>SvCUR</code>. Access the character as *(SvEND(sv)).</p> <pre><code class="plaintext">char* SvEND(SV* sv)</code></pre> </dd> <dt id="SvGROW"><a class="permalink" href="#SvGROW">#</a>SvGROW</dt> <dd> <p>Expands the character buffer in the SV so that it has room for the indicated number of bytes (remember to reserve space for an extra trailing NUL character). Calls <code>sv_grow</code> to perform the expansion if necessary. Returns a pointer to the character buffer.</p> <pre><code class="plaintext">char * SvGROW(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvIOK"><a class="permalink" href="#SvIOK">#</a>SvIOK</dt> <dd> <p>Returns a boolean indicating whether the SV contains an integer.</p> <pre><code class="plaintext">bool SvIOK(SV* sv)</code></pre> </dd> <dt id="SvIOKp"><a class="permalink" href="#SvIOKp">#</a>SvIOKp</dt> <dd> <p>Returns a boolean indicating whether the SV contains an integer. Checks the <b>private</b> setting. Use <code>SvIOK</code>.</p> <pre><code class="plaintext">bool SvIOKp(SV* sv)</code></pre> </dd> <dt id="SvIOK_notUV"><a class="permalink" href="#SvIOK_notUV">#</a>SvIOK_notUV</dt> <dd> <p>Returns a boolean indicating whether the SV contains a signed integer.</p> <pre><code class="plaintext">void SvIOK_notUV(SV* sv)</code></pre> </dd> <dt id="SvIOK_off"><a class="permalink" href="#SvIOK_off">#</a>SvIOK_off</dt> <dd> <p>Unsets the IV status of an SV.</p> <pre><code class="plaintext">void SvIOK_off(SV* sv)</code></pre> </dd> <dt id="SvIOK_on"><a class="permalink" href="#SvIOK_on">#</a>SvIOK_on</dt> <dd> <p>Tells an SV that it is an integer.</p> <pre><code class="plaintext">void SvIOK_on(SV* sv)</code></pre> </dd> <dt id="SvIOK_only"><a class="permalink" href="#SvIOK_only">#</a>SvIOK_only</dt> <dd> <p>Tells an SV that it is an integer and disables all other OK bits.</p> <pre><code class="plaintext">void SvIOK_only(SV* sv)</code></pre> </dd> <dt id="SvIOK_only_UV"><a class="permalink" href="#SvIOK_only_UV">#</a>SvIOK_only_UV</dt> <dd> <p>Tells and SV that it is an unsigned integer and disables all other OK bits.</p> <pre><code class="plaintext">void SvIOK_only_UV(SV* sv)</code></pre> </dd> <dt id="SvIOK_UV"><a class="permalink" href="#SvIOK_UV">#</a>SvIOK_UV</dt> <dd> <p>Returns a boolean indicating whether the SV contains an unsigned integer.</p> <pre><code class="plaintext">void SvIOK_UV(SV* sv)</code></pre> </dd> <dt id="SvIsCOW"><a class="permalink" href="#SvIsCOW">#</a>SvIsCOW</dt> <dd> <p>Returns a boolean indicating whether the SV is Copy-On-Write. (either shared hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for COW)</p> <pre><code class="plaintext">bool SvIsCOW(SV* sv)</code></pre> </dd> <dt id="SvIsCOW_shared_hash"><a class="permalink" href="#SvIsCOW_shared_hash">#</a>SvIsCOW_shared_hash</dt> <dd> <p>Returns a boolean indicating whether the SV is Copy-On-Write shared hash key scalar.</p> <pre><code class="plaintext">bool SvIsCOW_shared_hash(SV* sv)</code></pre> </dd> <dt id="SvIV"><a class="permalink" href="#SvIV">#</a>SvIV</dt> <dd> <p>Coerces the given SV to an integer and returns it. See <code>SvIVx</code> for a version which guarantees to evaluate sv only once.</p> <pre><code class="plaintext">IV SvIV(SV* sv)</code></pre> </dd> <dt id="SvIVX"><a class="permalink" href="#SvIVX">#</a>SvIVX</dt> <dd> <p>Returns the raw value in the SV's IV slot, without checks or conversions. Only use when you are sure SvIOK is true. See also <code>SvIV()</code>.</p> <pre><code class="plaintext">IV SvIVX(SV* sv)</code></pre> </dd> <dt id="SvIVx"><a class="permalink" href="#SvIVx">#</a>SvIVx</dt> <dd> <p>Coerces the given SV to an integer and returns it. Guarantees to evaluate sv only once. Use the more efficient <code>SvIV</code> otherwise.</p> <pre><code class="plaintext">IV SvIVx(SV* sv)</code></pre> </dd> <dt id="SvLEN"><a class="permalink" href="#SvLEN">#</a>SvLEN</dt> <dd> <p>Returns the size of the string buffer in the SV, not including any part attributable to <code>SvOOK</code>. See <code>SvCUR</code>.</p> <pre><code class="plaintext">STRLEN SvLEN(SV* sv)</code></pre> </dd> <dt id="SvNIOK"><a class="permalink" href="#SvNIOK">#</a>SvNIOK</dt> <dd> <p>Returns a boolean indicating whether the SV contains a number, integer or double.</p> <pre><code class="plaintext">bool SvNIOK(SV* sv)</code></pre> </dd> <dt id="SvNIOKp"><a class="permalink" href="#SvNIOKp">#</a>SvNIOKp</dt> <dd> <p>Returns a boolean indicating whether the SV contains a number, integer or double. Checks the <b>private</b> setting. Use <code>SvNIOK</code>.</p> <pre><code class="plaintext">bool SvNIOKp(SV* sv)</code></pre> </dd> <dt id="SvNIOK_off"><a class="permalink" href="#SvNIOK_off">#</a>SvNIOK_off</dt> <dd> <p>Unsets the NV/IV status of an SV.</p> <pre><code class="plaintext">void SvNIOK_off(SV* sv)</code></pre> </dd> <dt id="SvNOK"><a class="permalink" href="#SvNOK">#</a>SvNOK</dt> <dd> <p>Returns a boolean indicating whether the SV contains a double.</p> <pre><code class="plaintext">bool SvNOK(SV* sv)</code></pre> </dd> <dt id="SvNOKp"><a class="permalink" href="#SvNOKp">#</a>SvNOKp</dt> <dd> <p>Returns a boolean indicating whether the SV contains a double. Checks the <b>private</b> setting. Use <code>SvNOK</code>.</p> <pre><code class="plaintext">bool SvNOKp(SV* sv)</code></pre> </dd> <dt id="SvNOK_off"><a class="permalink" href="#SvNOK_off">#</a>SvNOK_off</dt> <dd> <p>Unsets the NV status of an SV.</p> <pre><code class="plaintext">void SvNOK_off(SV* sv)</code></pre> </dd> <dt id="SvNOK_on"><a class="permalink" href="#SvNOK_on">#</a>SvNOK_on</dt> <dd> <p>Tells an SV that it is a double.</p> <pre><code class="plaintext">void SvNOK_on(SV* sv)</code></pre> </dd> <dt id="SvNOK_only"><a class="permalink" href="#SvNOK_only">#</a>SvNOK_only</dt> <dd> <p>Tells an SV that it is a double and disables all other OK bits.</p> <pre><code class="plaintext">void SvNOK_only(SV* sv)</code></pre> </dd> <dt id="SvNV"><a class="permalink" href="#SvNV">#</a>SvNV</dt> <dd> <p>Coerce the given SV to a double and return it. See <code>SvNVx</code> for a version which guarantees to evaluate sv only once.</p> <pre><code class="plaintext">NV SvNV(SV* sv)</code></pre> </dd> <dt id="SvNVx"><a class="permalink" href="#SvNVx">#</a>SvNVx</dt> <dd> <p>Coerces the given SV to a double and returns it. Guarantees to evaluate sv only once. Use the more efficient <code>SvNV</code> otherwise.</p> <pre><code class="plaintext">NV SvNVx(SV* sv)</code></pre> </dd> <dt id="SvNVX"><a class="permalink" href="#SvNVX">#</a>SvNVX</dt> <dd> <p>Returns the raw value in the SV's NV slot, without checks or conversions. Only use when you are sure SvNOK is true. See also <code>SvNV()</code>.</p> <pre><code class="plaintext">NV SvNVX(SV* sv)</code></pre> </dd> <dt id="SvOK"><a class="permalink" href="#SvOK">#</a>SvOK</dt> <dd> <p>Returns a boolean indicating whether the value is an SV.</p> <pre><code class="plaintext">bool SvOK(SV* sv)</code></pre> </dd> <dt id="SvOOK"><a class="permalink" href="#SvOOK">#</a>SvOOK</dt> <dd> <p>Returns a boolean indicating whether the SvIVX is a valid offset value for the SvPVX. This hack is used internally to speed up removal of characters from the beginning of a SvPV. When SvOOK is true, then the start of the allocated string buffer is really (SvPVX - SvIVX).</p> <pre><code class="plaintext">bool SvOOK(SV* sv)</code></pre> </dd> <dt id="SvPOK"><a class="permalink" href="#SvPOK">#</a>SvPOK</dt> <dd> <p>Returns a boolean indicating whether the SV contains a character string.</p> <pre><code class="plaintext">bool SvPOK(SV* sv)</code></pre> </dd> <dt id="SvPOKp"><a class="permalink" href="#SvPOKp">#</a>SvPOKp</dt> <dd> <p>Returns a boolean indicating whether the SV contains a character string. Checks the <b>private</b> setting. Use <code>SvPOK</code>.</p> <pre><code class="plaintext">bool SvPOKp(SV* sv)</code></pre> </dd> <dt id="SvPOK_off"><a class="permalink" href="#SvPOK_off">#</a>SvPOK_off</dt> <dd> <p>Unsets the PV status of an SV.</p> <pre><code class="plaintext">void SvPOK_off(SV* sv)</code></pre> </dd> <dt id="SvPOK_on"><a class="permalink" href="#SvPOK_on">#</a>SvPOK_on</dt> <dd> <p>Tells an SV that it is a string.</p> <pre><code class="plaintext">void SvPOK_on(SV* sv)</code></pre> </dd> <dt id="SvPOK_only"><a class="permalink" href="#SvPOK_only">#</a>SvPOK_only</dt> <dd> <p>Tells an SV that it is a string and disables all other OK bits. Will also turn off the UTF-8 status.</p> <pre><code class="plaintext">void SvPOK_only(SV* sv)</code></pre> </dd> <dt id="SvPOK_only_UTF8"><a class="permalink" href="#SvPOK_only_UTF8">#</a>SvPOK_only_UTF8</dt> <dd> <p>Tells an SV that it is a string and disables all other OK bits, and leaves the UTF-8 status as it was.</p> <pre><code class="plaintext">void SvPOK_only_UTF8(SV* sv)</code></pre> </dd> <dt id="SvPV"><a class="permalink" href="#SvPV">#</a>SvPV</dt> <dd> <p>Returns a pointer to the string in the SV, or a stringified form of the SV if the SV does not contain a string. The SV may cache the stringified version becoming <code>SvPOK</code>. Handles 'get' magic. See also <code>SvPVx</code> for a version which guarantees to evaluate sv only once.</p> <pre><code class="plaintext">char* SvPV(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVbyte"><a class="permalink" href="#SvPVbyte">#</a>SvPVbyte</dt> <dd> <p>Like <code>SvPV</code>, but converts sv to byte representation first if necessary.</p> <pre><code class="plaintext">char* SvPVbyte(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVbytex"><a class="permalink" href="#SvPVbytex">#</a>SvPVbytex</dt> <dd> <p>Like <code>SvPV</code>, but converts sv to byte representation first if necessary. Guarantees to evaluate sv only once; use the more efficient <code>SvPVbyte</code> otherwise.</p> <pre><code class="plaintext">char* SvPVbytex(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVbytex_force"><a class="permalink" href="#SvPVbytex_force">#</a>SvPVbytex_force</dt> <dd> <p>Like <code>SvPV_force</code>, but converts sv to byte representation first if necessary. Guarantees to evaluate sv only once; use the more efficient <code>SvPVbyte_force</code> otherwise.</p> <pre><code class="plaintext">char* SvPVbytex_force(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVbyte_force"><a class="permalink" href="#SvPVbyte_force">#</a>SvPVbyte_force</dt> <dd> <p>Like <code>SvPV_force</code>, but converts sv to byte representation first if necessary.</p> <pre><code class="plaintext">char* SvPVbyte_force(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVbyte_nolen"><a class="permalink" href="#SvPVbyte_nolen">#</a>SvPVbyte_nolen</dt> <dd> <p>Like <code>SvPV_nolen</code>, but converts sv to byte representation first if necessary.</p> <pre><code class="plaintext">char* SvPVbyte_nolen(SV* sv)</code></pre> </dd> <dt id="SvPVutf8"><a class="permalink" href="#SvPVutf8">#</a>SvPVutf8</dt> <dd> <p>Like <code>SvPV</code>, but converts sv to utf8 first if necessary.</p> <pre><code class="plaintext">char* SvPVutf8(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVutf8x"><a class="permalink" href="#SvPVutf8x">#</a>SvPVutf8x</dt> <dd> <p>Like <code>SvPV</code>, but converts sv to utf8 first if necessary. Guarantees to evaluate sv only once; use the more efficient <code>SvPVutf8</code> otherwise.</p> <pre><code class="plaintext">char* SvPVutf8x(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVutf8x_force"><a class="permalink" href="#SvPVutf8x_force">#</a>SvPVutf8x_force</dt> <dd> <p>Like <code>SvPV_force</code>, but converts sv to utf8 first if necessary. Guarantees to evaluate sv only once; use the more efficient <code>SvPVutf8_force</code> otherwise.</p> <pre><code class="plaintext">char* SvPVutf8x_force(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVutf8_force"><a class="permalink" href="#SvPVutf8_force">#</a>SvPVutf8_force</dt> <dd> <p>Like <code>SvPV_force</code>, but converts sv to utf8 first if necessary.</p> <pre><code class="plaintext">char* SvPVutf8_force(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPVutf8_nolen"><a class="permalink" href="#SvPVutf8_nolen">#</a>SvPVutf8_nolen</dt> <dd> <p>Like <code>SvPV_nolen</code>, but converts sv to utf8 first if necessary.</p> <pre><code class="plaintext">char* SvPVutf8_nolen(SV* sv)</code></pre> </dd> <dt id="SvPVX"><a class="permalink" href="#SvPVX">#</a>SvPVX</dt> <dd> <p>Returns a pointer to the physical string in the SV. The SV must contain a string.</p> <pre><code class="plaintext">char* SvPVX(SV* sv)</code></pre> </dd> <dt id="SvPVx"><a class="permalink" href="#SvPVx">#</a>SvPVx</dt> <dd> <p>A version of <code>SvPV</code> which guarantees to evaluate sv only once.</p> <pre><code class="plaintext">char* SvPVx(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPV_force"><a class="permalink" href="#SvPV_force">#</a>SvPV_force</dt> <dd> <p>Like <code>SvPV</code> but will force the SV into containing just a string (<code>SvPOK_only</code>). You want force if you are going to update the <code>SvPVX</code> directly.</p> <pre><code class="plaintext">char* SvPV_force(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPV_force_nomg"><a class="permalink" href="#SvPV_force_nomg">#</a>SvPV_force_nomg</dt> <dd> <p>Like <code>SvPV</code> but will force the SV into containing just a string (<code>SvPOK_only</code>). You want force if you are going to update the <code>SvPVX</code> directly. Doesn't process magic.</p> <pre><code class="plaintext">char* SvPV_force_nomg(SV* sv, STRLEN len)</code></pre> </dd> <dt id="SvPV_nolen"><a class="permalink" href="#SvPV_nolen">#</a>SvPV_nolen</dt> <dd> <p>Returns a pointer to the string in the SV, or a stringified form of the SV if the SV does not contain a string. The SV may cache the stringified form becoming <code>SvPOK</code>. Handles 'get' magic.</p> <pre><code class="plaintext">char* SvPV_nolen(SV* sv)</code></pre> </dd> <dt id="SvREFCNT"><a class="permalink" href="#SvREFCNT">#</a>SvREFCNT</dt> <dd> <p>Returns the value of the object's reference count.</p> <pre><code class="plaintext">U32 SvREFCNT(SV* sv)</code></pre> </dd> <dt id="SvREFCNT_dec"><a class="permalink" href="#SvREFCNT_dec">#</a>SvREFCNT_dec</dt> <dd> <p>Decrements the reference count of the given SV.</p> <pre><code class="plaintext">void SvREFCNT_dec(SV* sv)</code></pre> </dd> <dt id="SvREFCNT_inc"><a class="permalink" href="#SvREFCNT_inc">#</a>SvREFCNT_inc</dt> <dd> <p>Increments the reference count of the given SV.</p> <pre><code class="plaintext">SV* SvREFCNT_inc(SV* sv)</code></pre> </dd> <dt id="SvROK"><a class="permalink" href="#SvROK">#</a>SvROK</dt> <dd> <p>Tests if the SV is an RV.</p> <pre><code class="plaintext">bool SvROK(SV* sv)</code></pre> </dd> <dt id="SvROK_off"><a class="permalink" href="#SvROK_off">#</a>SvROK_off</dt> <dd> <p>Unsets the RV status of an SV.</p> <pre><code class="plaintext">void SvROK_off(SV* sv)</code></pre> </dd> <dt id="SvROK_on"><a class="permalink" href="#SvROK_on">#</a>SvROK_on</dt> <dd> <p>Tells an SV that it is an RV.</p> <pre><code class="plaintext">void SvROK_on(SV* sv)</code></pre> </dd> <dt id="SvRV"><a class="permalink" href="#SvRV">#</a>SvRV</dt> <dd> <p>Dereferences an RV to return the SV.</p> <pre><code class="plaintext">SV* SvRV(SV* sv)</code></pre> </dd> <dt id="SvSTASH"><a class="permalink" href="#SvSTASH">#</a>SvSTASH</dt> <dd> <p>Returns the stash of the SV.</p> <pre><code class="plaintext">HV* SvSTASH(SV* sv)</code></pre> </dd> <dt id="SvTAINT"><a class="permalink" href="#SvTAINT">#</a>SvTAINT</dt> <dd> <p>Taints an SV if tainting is enabled.</p> <pre><code class="plaintext">void SvTAINT(SV* sv)</code></pre> </dd> <dt id="SvTAINTED"><a class="permalink" href="#SvTAINTED">#</a>SvTAINTED</dt> <dd> <p>Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if not.</p> <pre><code class="plaintext">bool SvTAINTED(SV* sv)</code></pre> </dd> <dt id="SvTAINTED_off"><a class="permalink" href="#SvTAINTED_off">#</a>SvTAINTED_off</dt> <dd> <p>Untaints an SV. Be <i>very</i> careful with this routine, as it short-circuits some of Perl's fundamental security features. XS module authors should not use this function unless they fully understand all the implications of unconditionally untainting the value. Untainting should be done in the standard perl fashion, via a carefully crafted regexp, rather than directly untainting variables.</p> <pre><code class="plaintext">void SvTAINTED_off(SV* sv)</code></pre> </dd> <dt id="SvTAINTED_on"><a class="permalink" href="#SvTAINTED_on">#</a>SvTAINTED_on</dt> <dd> <p>Marks an SV as tainted if tainting is enabled.</p> <pre><code class="plaintext">void SvTAINTED_on(SV* sv)</code></pre> </dd> <dt id="SvTRUE"><a class="permalink" href="#SvTRUE">#</a>SvTRUE</dt> <dd> <p>Returns a boolean indicating whether Perl would evaluate the SV as true or false, defined or undefined. Does not handle 'get' magic.</p> <pre><code class="plaintext">bool SvTRUE(SV* sv)</code></pre> </dd> <dt id="SvTYPE"><a class="permalink" href="#SvTYPE">#</a>SvTYPE</dt> <dd> <p>Returns the type of the SV. See <code>svtype</code>.</p> <pre><code class="plaintext">svtype SvTYPE(SV* sv)</code></pre> </dd> <dt id="SvUNLOCK"><a class="permalink" href="#SvUNLOCK">#</a>SvUNLOCK</dt> <dd> <p>Releases a mutual exclusion lock on sv if a suitable module has been loaded.</p> <pre><code class="plaintext">void SvUNLOCK(SV* sv)</code></pre> </dd> <dt id="SvUOK"><a class="permalink" href="#SvUOK">#</a>SvUOK</dt> <dd> <p>Returns a boolean indicating whether the SV contains an unsigned integer.</p> <pre><code class="plaintext">void SvUOK(SV* sv)</code></pre> </dd> <dt id="SvUPGRADE"><a class="permalink" href="#SvUPGRADE">#</a>SvUPGRADE</dt> <dd> <p>Used to upgrade an SV to a more complex form. Uses <code>sv_upgrade</code> to perform the upgrade if necessary. See <code>svtype</code>.</p> <pre><code class="plaintext">void SvUPGRADE(SV* sv, svtype type)</code></pre> </dd> <dt id="SvUTF8"><a class="permalink" href="#SvUTF8">#</a>SvUTF8</dt> <dd> <p>Returns a boolean indicating whether the SV contains UTF-8 encoded data.</p> <pre><code class="plaintext">void SvUTF8(SV* sv)</code></pre> </dd> <dt id="SvUTF8_off"><a class="permalink" href="#SvUTF8_off">#</a>SvUTF8_off</dt> <dd> <p>Unsets the UTF-8 status of an SV.</p> <pre><code class="plaintext">void SvUTF8_off(SV *sv)</code></pre> </dd> <dt id="SvUTF8_on"><a class="permalink" href="#SvUTF8_on">#</a>SvUTF8_on</dt> <dd> <p>Turn on the UTF-8 status of an SV (the data is not changed, just the flag). Do not use frivolously.</p> <pre><code class="plaintext">void SvUTF8_on(SV *sv)</code></pre> </dd> <dt id="SvUV"><a class="permalink" href="#SvUV">#</a>SvUV</dt> <dd> <p>Coerces the given SV to an unsigned integer and returns it. See <code>SvUVx</code> for a version which guarantees to evaluate sv only once.</p> <pre><code class="plaintext">UV SvUV(SV* sv)</code></pre> </dd> <dt id="SvUVX"><a class="permalink" href="#SvUVX">#</a>SvUVX</dt> <dd> <p>Returns the raw value in the SV's UV slot, without checks or conversions. Only use when you are sure SvIOK is true. See also <code>SvUV()</code>.</p> <pre><code class="plaintext">UV SvUVX(SV* sv)</code></pre> </dd> <dt id="SvUVx"><a class="permalink" href="#SvUVx">#</a>SvUVx</dt> <dd> <p>Coerces the given SV to an unsigned integer and returns it. Guarantees to evaluate sv only once. Use the more efficient <code>SvUV</code> otherwise.</p> <pre><code class="plaintext">UV SvUVx(SV* sv)</code></pre> </dd> <dt id="sv_2bool"><a class="permalink" href="#sv_2bool">#</a>sv_2bool</dt> <dd> <p>This function is only called on magical items, and is only used by sv_true() or its macro equivalent.</p> <pre><code class="plaintext">bool sv_2bool(SV* sv)</code></pre> </dd> <dt id="sv_2cv"><a class="permalink" href="#sv_2cv">#</a>sv_2cv</dt> <dd> <p>Using various gambits, try to get a CV from an SV; in addition, try if possible to set <code>*st</code> and <code>*gvp</code> to the stash and GV associated with it.</p> <pre><code class="plaintext">CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)</code></pre> </dd> <dt id="sv_2io"><a class="permalink" href="#sv_2io">#</a>sv_2io</dt> <dd> <p>Using various gambits, try to get an IO from an SV: the IO slot if its a GV; or the recursive result if we're an RV; or the IO slot of the symbol named after the PV if we're a string.</p> <pre><code class="plaintext">IO* sv_2io(SV* sv)</code></pre> </dd> <dt id="sv_2iv"><a class="permalink" href="#sv_2iv">#</a>sv_2iv</dt> <dd> <p>Return the integer value of an SV, doing any necessary string conversion, magic etc. Normally used via the <code>SvIV(sv)</code> and <code>SvIVx(sv)</code> macros.</p> <pre><code class="plaintext">IV sv_2iv(SV* sv)</code></pre> </dd> <dt id="sv_2mortal"><a class="permalink" href="#sv_2mortal">#</a>sv_2mortal</dt> <dd> <p>Marks an existing SV as mortal. The SV will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also <code>sv_newmortal</code> and <code>sv_mortalcopy</code>.</p> <pre><code class="plaintext">SV* sv_2mortal(SV* sv)</code></pre> </dd> <dt id="sv_2nv"><a class="permalink" href="#sv_2nv">#</a>sv_2nv</dt> <dd> <p>Return the num value of an SV, doing any necessary string or integer conversion, magic etc. Normally used via the <code>SvNV(sv)</code> and <code>SvNVx(sv)</code> macros.</p> <pre><code class="plaintext">NV sv_2nv(SV* sv)</code></pre> </dd> <dt id="sv_2pvbyte"><a class="permalink" href="#sv_2pvbyte">#</a>sv_2pvbyte</dt> <dd> <p>Return a pointer to the byte-encoded representation of the SV, and set *lp to its length. May cause the SV to be downgraded from UTF-8 as a side-effect.</p> <p>Usually accessed via the <code>SvPVbyte</code> macro.</p> <pre><code class="plaintext">char* sv_2pvbyte(SV* sv, STRLEN* lp)</code></pre> </dd> <dt id="sv_2pvbyte_nolen"><a class="permalink" href="#sv_2pvbyte_nolen">#</a>sv_2pvbyte_nolen</dt> <dd> <p>Return a pointer to the byte-encoded representation of the SV. May cause the SV to be downgraded from UTF-8 as a side-effect.</p> <p>Usually accessed via the <code>SvPVbyte_nolen</code> macro.</p> <pre><code class="plaintext">char* sv_2pvbyte_nolen(SV* sv)</code></pre> </dd> <dt id="sv_2pvutf8"><a class="permalink" href="#sv_2pvutf8">#</a>sv_2pvutf8</dt> <dd> <p>Return a pointer to the UTF-8-encoded representation of the SV, and set *lp to its length. May cause the SV to be upgraded to UTF-8 as a side-effect.</p> <p>Usually accessed via the <code>SvPVutf8</code> macro.</p> <pre><code class="plaintext">char* sv_2pvutf8(SV* sv, STRLEN* lp)</code></pre> </dd> <dt id="sv_2pvutf8_nolen"><a class="permalink" href="#sv_2pvutf8_nolen">#</a>sv_2pvutf8_nolen</dt> <dd> <p>Return a pointer to the UTF-8-encoded representation of the SV. May cause the SV to be upgraded to UTF-8 as a side-effect.</p> <p>Usually accessed via the <code>SvPVutf8_nolen</code> macro.</p> <pre><code class="plaintext">char* sv_2pvutf8_nolen(SV* sv)</code></pre> </dd> <dt id="sv_2pv_flags"><a class="permalink" href="#sv_2pv_flags">#</a>sv_2pv_flags</dt> <dd> <p>Returns a pointer to the string value of an SV, and sets *lp to its length. If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string if necessary. Normally invoked via the <code>SvPV_flags</code> macro. <code>sv_2pv()</code> and <code>sv_2pv_nomg</code> usually end up here too.</p> <pre><code class="plaintext">char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags)</code></pre> </dd> <dt id="sv_2pv_nolen"><a class="permalink" href="#sv_2pv_nolen">#</a>sv_2pv_nolen</dt> <dd> <p>Like <code>sv_2pv()</code>, but doesn't return the length too. You should usually use the macro wrapper <code>SvPV_nolen(sv)</code> instead. char* sv_2pv_nolen(SV* sv)</p> </dd> <dt id="sv_2uv"><a class="permalink" href="#sv_2uv">#</a>sv_2uv</dt> <dd> <p>Return the unsigned integer value of an SV, doing any necessary string conversion, magic etc. Normally used via the <code>SvUV(sv)</code> and <code>SvUVx(sv)</code> macros.</p> <pre><code class="plaintext">UV sv_2uv(SV* sv)</code></pre> </dd> <dt id="sv_backoff"><a class="permalink" href="#sv_backoff">#</a>sv_backoff</dt> <dd> <p>Remove any string offset. You should normally use the <code>SvOOK_off</code> macro wrapper instead.</p> <pre><code class="plaintext">int sv_backoff(SV* sv)</code></pre> </dd> <dt id="sv_bless"><a class="permalink" href="#sv_bless">#</a>sv_bless</dt> <dd> <p>Blesses an SV into a specified package. The SV must be an RV. The package must be designated by its stash (see <code>gv_stashpv()</code>). The reference count of the SV is unaffected.</p> <pre><code class="plaintext">SV* sv_bless(SV* sv, HV* stash)</code></pre> </dd> <dt id="sv_catpv"><a class="permalink" href="#sv_catpv">#</a>sv_catpv</dt> <dd> <p>Concatenates the string onto the end of the string which is in the SV. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic. See <code>sv_catpv_mg</code>.</p> <pre><code class="plaintext">void sv_catpv(SV* sv, const char* ptr)</code></pre> </dd> <dt id="sv_catpvf"><a class="permalink" href="#sv_catpvf">#</a>sv_catpvf</dt> <dd> <p>Processes its arguments like <code>sprintf</code> and appends the formatted output to an SV. If the appended data contains "wide" characters (including, but not limited to, SVs with a UTF-8 PV formatted with %s, and characters >255 formatted with %c), the original SV might get upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. <code>SvSETMAGIC()</code> must typically be called after calling this function to handle 'set' magic.</p> <pre><code class="plaintext">void sv_catpvf(SV* sv, const char* pat, ...)</code></pre> </dd> <dt id="sv_catpvf_mg"><a class="permalink" href="#sv_catpvf_mg">#</a>sv_catpvf_mg</dt> <dd> <p>Like <code>sv_catpvf</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_catpvf_mg(SV *sv, const char* pat, ...)</code></pre> </dd> <dt id="sv_catpvn"><a class="permalink" href="#sv_catpvn">#</a>sv_catpvn</dt> <dd> <p>Concatenates the string onto the end of the string which is in the SV. The <code>len</code> indicates number of bytes to copy. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic. See <code>sv_catpvn_mg</code>.</p> <pre><code class="plaintext">void sv_catpvn(SV* sv, const char* ptr, STRLEN len)</code></pre> </dd> <dt id="sv_catpvn_flags"><a class="permalink" href="#sv_catpvn_flags">#</a>sv_catpvn_flags</dt> <dd> <p>Concatenates the string onto the end of the string which is in the SV. The <code>len</code> indicates number of bytes to copy. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. If <code>flags</code> has <code>SV_GMAGIC</code> bit set, will <code>mg_get</code> on <code>dsv</code> if appropriate, else not. <code>sv_catpvn</code> and <code>sv_catpvn_nomg</code> are implemented in terms of this function.</p> <pre><code class="plaintext">void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags)</code></pre> </dd> <dt id="sv_catpvn_mg"><a class="permalink" href="#sv_catpvn_mg">#</a>sv_catpvn_mg</dt> <dd> <p>Like <code>sv_catpvn</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)</code></pre> </dd> <dt id="sv_catpv_mg"><a class="permalink" href="#sv_catpv_mg">#</a>sv_catpv_mg</dt> <dd> <p>Like <code>sv_catpv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_catpv_mg(SV *sv, const char *ptr)</code></pre> </dd> <dt id="sv_catsv"><a class="permalink" href="#sv_catsv">#</a>sv_catsv</dt> <dd> <p>Concatenates the string from SV <code>ssv</code> onto the end of the string in SV <code>dsv</code>. Modifies <code>dsv</code> but not <code>ssv</code>. Handles 'get' magic, but not 'set' magic. See <code>sv_catsv_mg</code>.</p> <pre><code class="plaintext">void sv_catsv(SV* dsv, SV* ssv)</code></pre> </dd> <dt id="sv_catsv_flags"><a class="permalink" href="#sv_catsv_flags">#</a>sv_catsv_flags</dt> <dd> <p>Concatenates the string from SV <code>ssv</code> onto the end of the string in SV <code>dsv</code>. Modifies <code>dsv</code> but not <code>ssv</code>. If <code>flags</code> has <code>SV_GMAGIC</code> bit set, will <code>mg_get</code> on the SVs if appropriate, else not. <code>sv_catsv</code> and <code>sv_catsv_nomg</code> are implemented in terms of this function.</p> <pre><code class="plaintext">void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags)</code></pre> </dd> <dt id="sv_catsv_mg"><a class="permalink" href="#sv_catsv_mg">#</a>sv_catsv_mg</dt> <dd> <p>Like <code>sv_catsv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_catsv_mg(SV *dstr, SV *sstr)</code></pre> </dd> <dt id="sv_chop"><a class="permalink" href="#sv_chop">#</a>sv_chop</dt> <dd> <p>Efficient removal of characters from the beginning of the string buffer. SvPOK(sv) must be true and the <code>ptr</code> must be a pointer to somewhere inside the string buffer. The <code>ptr</code> becomes the first character of the adjusted string. Uses the "OOK hack". Beware: after this function returns, <code>ptr</code> and SvPVX(sv) may no longer refer to the same chunk of data.</p> <pre><code class="plaintext">void sv_chop(SV* sv, char* ptr)</code></pre> </dd> <dt id="sv_clear"><a class="permalink" href="#sv_clear">#</a>sv_clear</dt> <dd> <p>Clear an SV: call any destructors, free up any memory used by the body, and free the body itself. The SV's head is <i>not</i> freed, although its type is set to all 1's so that it won't inadvertently be assumed to be live during global destruction etc. This function should only be called when REFCNT is zero. Most of the time you'll want to call <code>sv_free()</code> (or its macro wrapper <code>SvREFCNT_dec</code>) instead.</p> <pre><code class="plaintext">void sv_clear(SV* sv)</code></pre> </dd> <dt id="sv_cmp"><a class="permalink" href="#sv_cmp">#</a>sv_cmp</dt> <dd> <p>Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the string in <code>sv1</code> is less than, equal to, or greater than the string in <code>sv2</code>. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also <code>sv_cmp_locale</code>.</p> <pre><code class="plaintext">I32 sv_cmp(SV* sv1, SV* sv2)</code></pre> </dd> <dt id="sv_cmp_locale"><a class="permalink" href="#sv_cmp_locale">#</a>sv_cmp_locale</dt> <dd> <p>Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also <code>sv_cmp_locale</code>. See also <code>sv_cmp</code>.</p> <pre><code class="plaintext">I32 sv_cmp_locale(SV* sv1, SV* sv2)</code></pre> </dd> <dt id="sv_collxfrm"><a class="permalink" href="#sv_collxfrm">#</a>sv_collxfrm</dt> <dd> <p>Add Collate Transform magic to an SV if it doesn't already have it.</p> <p>Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the scalar data of the variable, but transformed to such a format that a normal memory comparison can be used to compare the data according to the locale settings.</p> <pre><code class="plaintext">char* sv_collxfrm(SV* sv, STRLEN* nxp)</code></pre> </dd> <dt id="sv_copypv"><a class="permalink" href="#sv_copypv">#</a>sv_copypv</dt> <dd> <p>Copies a stringified representation of the source SV into the destination SV. Automatically performs any necessary mg_get and coercion of numeric values into strings. Guaranteed to preserve UTF-8 flag even from overloaded objects. Similar in nature to sv_2pv[_flags] but operates directly on an SV instead of just the string. Mostly uses sv_2pv_flags to do its work, except when that would lose the UTF-8'ness of the PV.</p> <pre><code class="plaintext">void sv_copypv(SV* dsv, SV* ssv)</code></pre> </dd> <dt id="sv_dec"><a class="permalink" href="#sv_dec">#</a>sv_dec</dt> <dd> <p>Auto-decrement of the value in the SV, doing string to numeric conversion if necessary. Handles 'get' magic.</p> <pre><code class="plaintext">void sv_dec(SV* sv)</code></pre> </dd> <dt id="sv_derived_from"><a class="permalink" href="#sv_derived_from">#</a>sv_derived_from</dt> <dd> <p>Returns a boolean indicating whether the SV is derived from the specified class. This is the function that implements <code>UNIVERSAL::isa</code>. It works for class names as well as for objects.</p> <pre><code class="plaintext">bool sv_derived_from(SV* sv, const char* name)</code></pre> </dd> <dt id="sv_eq"><a class="permalink" href="#sv_eq">#</a>sv_eq</dt> <dd> <p>Returns a boolean indicating whether the strings in the two SVs are identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary.</p> <pre><code class="plaintext">I32 sv_eq(SV* sv1, SV* sv2)</code></pre> </dd> <dt id="sv_force_normal"><a class="permalink" href="#sv_force_normal">#</a>sv_force_normal</dt> <dd> <p>Undo various types of fakery on an SV: if the PV is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an xpvmg. See also <code>sv_force_normal_flags</code>.</p> <pre><code class="plaintext">void sv_force_normal(SV *sv)</code></pre> </dd> <dt id="sv_force_normal_flags"><a class="permalink" href="#sv_force_normal_flags">#</a>sv_force_normal_flags</dt> <dd> <p>Undo various types of fakery on an SV: if the PV is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an xpvmg. The <code>flags</code> parameter gets passed to <code>sv_unref_flags()</code> when unrefing. <code>sv_force_normal</code> calls this function with flags set to 0.</p> <pre><code class="plaintext">void sv_force_normal_flags(SV *sv, U32 flags)</code></pre> </dd> <dt id="sv_free"><a class="permalink" href="#sv_free">#</a>sv_free</dt> <dd> <p>Decrement an SV's reference count, and if it drops to zero, call <code>sv_clear</code> to invoke destructors and free up any memory used by the body; finally, deallocate the SV's head itself. Normally called via a wrapper macro <code>SvREFCNT_dec</code>.</p> <pre><code class="plaintext">void sv_free(SV* sv)</code></pre> </dd> <dt id="sv_gets"><a class="permalink" href="#sv_gets">#</a>sv_gets</dt> <dd> <p>Get a line from the filehandle and store it into the SV, optionally appending to the currently-stored string.</p> <pre><code class="plaintext">char* sv_gets(SV* sv, PerlIO* fp, I32 append)</code></pre> </dd> <dt id="sv_grow"><a class="permalink" href="#sv_grow">#</a>sv_grow</dt> <dd> <p>Expands the character buffer in the SV. If necessary, uses <code>sv_unref</code> and upgrades the SV to <code>SVt_PV</code>. Returns a pointer to the character buffer. Use the <code>SvGROW</code> wrapper instead.</p> <pre><code class="plaintext">char* sv_grow(SV* sv, STRLEN newlen)</code></pre> </dd> <dt id="sv_inc"><a class="permalink" href="#sv_inc">#</a>sv_inc</dt> <dd> <p>Auto-increment of the value in the SV, doing string to numeric conversion if necessary. Handles 'get' magic.</p> <pre><code class="plaintext">void sv_inc(SV* sv)</code></pre> </dd> <dt id="sv_insert"><a class="permalink" href="#sv_insert">#</a>sv_insert</dt> <dd> <p>Inserts a string at the specified offset/length within the SV. Similar to the Perl substr() function.</p> <pre><code class="plaintext">void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, char* little, STRLEN littlelen)</code></pre> </dd> <dt id="sv_isa"><a class="permalink" href="#sv_isa">#</a>sv_isa</dt> <dd> <p>Returns a boolean indicating whether the SV is blessed into the specified class. This does not check for subtypes; use <code>sv_derived_from</code> to verify an inheritance relationship.</p> <pre><code class="plaintext">int sv_isa(SV* sv, const char* name)</code></pre> </dd> <dt id="sv_isobject"><a class="permalink" href="#sv_isobject">#</a>sv_isobject</dt> <dd> <p>Returns a boolean indicating whether the SV is an RV pointing to a blessed object. If the SV is not an RV, or if the object is not blessed, then this will return false.</p> <pre><code class="plaintext">int sv_isobject(SV* sv)</code></pre> </dd> <dt id="sv_iv"><a class="permalink" href="#sv_iv">#</a>sv_iv</dt> <dd> <p>A private implementation of the <code>SvIVx</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">IV sv_iv(SV* sv)</code></pre> </dd> <dt id="sv_len"><a class="permalink" href="#sv_len">#</a>sv_len</dt> <dd> <p>Returns the length of the string in the SV. Handles magic and type coercion. See also <code>SvCUR</code>, which gives raw access to the xpv_cur slot.</p> <pre><code class="plaintext">STRLEN sv_len(SV* sv)</code></pre> </dd> <dt id="sv_len_utf8"><a class="permalink" href="#sv_len_utf8">#</a>sv_len_utf8</dt> <dd> <p>Returns the number of characters in the string in an SV, counting wide UTF-8 bytes as a single character. Handles magic and type coercion.</p> <pre><code class="plaintext">STRLEN sv_len_utf8(SV* sv)</code></pre> </dd> <dt id="sv_magic"><a class="permalink" href="#sv_magic">#</a>sv_magic</dt> <dd> <p>Adds magic to an SV. First upgrades <code>sv</code> to type <code>SVt_PVMG</code> if necessary, then adds a new magic item of type <code>how</code> to the head of the magic list.</p> <pre><code class="plaintext">void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)</code></pre> </dd> <dt id="sv_magicext"><a class="permalink" href="#sv_magicext">#</a>sv_magicext</dt> <dd> <p>Adds magic to an SV, upgrading it if necessary. Applies the supplied vtable and returns pointer to the magic added.</p> <p>Note that sv_magicext will allow things that sv_magic will not. In particular you can add magic to SvREADONLY SVs and and more than one instance of the same 'how'</p> <p>I <code>namelen</code> is greater then zero then a savepvn() <i>copy</i> of <code>name</code> is stored, if <code>namelen</code> is zero then <code>name</code> is stored as-is and - as another special case - if <code>(name && namelen == HEf_SVKEY)</code> then <code>name</code> is assumed to contain an <code>SV*</code> and has its REFCNT incremented</p> <p>(This is now used as a subroutine by sv_magic.)</p> <pre><code class="plaintext">MAGIC * sv_magicext(SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen )</code></pre> </dd> <dt id="sv_mortalcopy"><a class="permalink" href="#sv_mortalcopy">#</a>sv_mortalcopy</dt> <dd> <p>Creates a new SV which is a copy of the original SV (using <code>sv_setsv</code>). The new SV is marked as mortal. It will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also <code>sv_newmortal</code> and <code>sv_2mortal</code>.</p> <pre><code class="plaintext">SV* sv_mortalcopy(SV* oldsv)</code></pre> </dd> <dt id="sv_newmortal"><a class="permalink" href="#sv_newmortal">#</a>sv_newmortal</dt> <dd> <p>Creates a new null SV which is mortal. The reference count of the SV is set to 1. It will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also <code>sv_mortalcopy</code> and <code>sv_2mortal</code>.</p> <pre><code class="plaintext">SV* sv_newmortal()</code></pre> </dd> <dt id="sv_newref"><a class="permalink" href="#sv_newref">#</a>sv_newref</dt> <dd> <p>Increment an SV's reference count. Use the <code>SvREFCNT_inc()</code> wrapper instead.</p> <pre><code class="plaintext">SV* sv_newref(SV* sv)</code></pre> </dd> <dt id="sv_nv"><a class="permalink" href="#sv_nv">#</a>sv_nv</dt> <dd> <p>A private implementation of the <code>SvNVx</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">NV sv_nv(SV* sv)</code></pre> </dd> <dt id="sv_pos_b2u"><a class="permalink" href="#sv_pos_b2u">#</a>sv_pos_b2u</dt> <dd> <p>Converts the value pointed to by offsetp from a count of bytes from the start of the string, to a count of the equivalent number of UTF-8 chars. Handles magic and type coercion.</p> <pre><code class="plaintext">void sv_pos_b2u(SV* sv, I32* offsetp)</code></pre> </dd> <dt id="sv_pos_u2b"><a class="permalink" href="#sv_pos_u2b">#</a>sv_pos_u2b</dt> <dd> <p>Converts the value pointed to by offsetp from a count of UTF-8 chars from the start of the string, to a count of the equivalent number of bytes; if lenp is non-zero, it does the same to lenp, but this time starting from the offset, rather than from the start of the string. Handles magic and type coercion.</p> <pre><code class="plaintext">void sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp)</code></pre> </dd> <dt id="sv_pv"><a class="permalink" href="#sv_pv">#</a>sv_pv</dt> <dd> <p>Use the <code>SvPV_nolen</code> macro instead</p> <pre><code class="plaintext">char* sv_pv(SV *sv)</code></pre> </dd> <dt id="sv_pvbyte"><a class="permalink" href="#sv_pvbyte">#</a>sv_pvbyte</dt> <dd> <p>Use <code>SvPVbyte_nolen</code> instead.</p> <pre><code class="plaintext">char* sv_pvbyte(SV *sv)</code></pre> </dd> <dt id="sv_pvbyten"><a class="permalink" href="#sv_pvbyten">#</a>sv_pvbyten</dt> <dd> <p>A private implementation of the <code>SvPVbyte</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvbyten(SV *sv, STRLEN *len)</code></pre> </dd> <dt id="sv_pvbyten_force"><a class="permalink" href="#sv_pvbyten_force">#</a>sv_pvbyten_force</dt> <dd> <p>A private implementation of the <code>SvPVbytex_force</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvbyten_force(SV* sv, STRLEN* lp)</code></pre> </dd> <dt id="sv_pvn"><a class="permalink" href="#sv_pvn">#</a>sv_pvn</dt> <dd> <p>A private implementation of the <code>SvPV</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvn(SV *sv, STRLEN *len)</code></pre> </dd> <dt id="sv_pvn_force"><a class="permalink" href="#sv_pvn_force">#</a>sv_pvn_force</dt> <dd> <p>Get a sensible string out of the SV somehow. A private implementation of the <code>SvPV_force</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvn_force(SV* sv, STRLEN* lp)</code></pre> </dd> <dt id="sv_pvn_force_flags"><a class="permalink" href="#sv_pvn_force_flags">#</a>sv_pvn_force_flags</dt> <dd> <p>Get a sensible string out of the SV somehow. If <code>flags</code> has <code>SV_GMAGIC</code> bit set, will <code>mg_get</code> on <code>sv</code> if appropriate, else not. <code>sv_pvn_force</code> and <code>sv_pvn_force_nomg</code> are implemented in terms of this function. You normally want to use the various wrapper macros instead: see <code>SvPV_force</code> and <code>SvPV_force_nomg</code></p> <pre><code class="plaintext">char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags)</code></pre> </dd> <dt id="sv_pvutf8"><a class="permalink" href="#sv_pvutf8">#</a>sv_pvutf8</dt> <dd> <p>Use the <code>SvPVutf8_nolen</code> macro instead</p> <pre><code class="plaintext">char* sv_pvutf8(SV *sv)</code></pre> </dd> <dt id="sv_pvutf8n"><a class="permalink" href="#sv_pvutf8n">#</a>sv_pvutf8n</dt> <dd> <p>A private implementation of the <code>SvPVutf8</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvutf8n(SV *sv, STRLEN *len)</code></pre> </dd> <dt id="sv_pvutf8n_force"><a class="permalink" href="#sv_pvutf8n_force">#</a>sv_pvutf8n_force</dt> <dd> <p>A private implementation of the <code>SvPVutf8_force</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">char* sv_pvutf8n_force(SV* sv, STRLEN* lp)</code></pre> </dd> <dt id="sv_reftype"><a class="permalink" href="#sv_reftype">#</a>sv_reftype</dt> <dd> <p>Returns a string describing what the SV is a reference to.</p> <pre><code class="plaintext">char* sv_reftype(SV* sv, int ob)</code></pre> </dd> <dt id="sv_replace"><a class="permalink" href="#sv_replace">#</a>sv_replace</dt> <dd> <p>Make the first argument a copy of the second, then delete the original. The target SV physically takes over ownership of the body of the source SV and inherits its flags; however, the target keeps any magic it owns, and any magic in the source is discarded. Note that this is a rather specialist SV copying operation; most of the time you'll want to use <code>sv_setsv</code> or one of its many macro front-ends.</p> <pre><code class="plaintext">void sv_replace(SV* sv, SV* nsv)</code></pre> </dd> <dt id="sv_report_used"><a class="permalink" href="#sv_report_used">#</a>sv_report_used</dt> <dd> <p>Dump the contents of all SVs not yet freed. (Debugging aid).</p> <pre><code class="plaintext">void sv_report_used()</code></pre> </dd> <dt id="sv_reset"><a class="permalink" href="#sv_reset">#</a>sv_reset</dt> <dd> <p>Underlying implementation for the <code>reset</code> Perl function. Note that the perl-level function is vaguely deprecated.</p> <pre><code class="plaintext">void sv_reset(char* s, HV* stash)</code></pre> </dd> <dt id="sv_rvweaken"><a class="permalink" href="#sv_rvweaken">#</a>sv_rvweaken</dt> <dd> <p>Weaken a reference: set the <code>SvWEAKREF</code> flag on this RV; give the referred-to SV <code>PERL_MAGIC_backref</code> magic if it hasn't already; and push a back-reference to this RV onto the array of backreferences associated with that magic.</p> <pre><code class="plaintext">SV* sv_rvweaken(SV *sv)</code></pre> </dd> <dt id="sv_setiv"><a class="permalink" href="#sv_setiv">#</a>sv_setiv</dt> <dd> <p>Copies an integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also <code>sv_setiv_mg</code>.</p> <pre><code class="plaintext">void sv_setiv(SV* sv, IV num)</code></pre> </dd> <dt id="sv_setiv_mg"><a class="permalink" href="#sv_setiv_mg">#</a>sv_setiv_mg</dt> <dd> <p>Like <code>sv_setiv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setiv_mg(SV *sv, IV i)</code></pre> </dd> <dt id="sv_setnv"><a class="permalink" href="#sv_setnv">#</a>sv_setnv</dt> <dd> <p>Copies a double into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also <code>sv_setnv_mg</code>.</p> <pre><code class="plaintext">void sv_setnv(SV* sv, NV num)</code></pre> </dd> <dt id="sv_setnv_mg"><a class="permalink" href="#sv_setnv_mg">#</a>sv_setnv_mg</dt> <dd> <p>Like <code>sv_setnv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setnv_mg(SV *sv, NV num)</code></pre> </dd> <dt id="sv_setpv"><a class="permalink" href="#sv_setpv">#</a>sv_setpv</dt> <dd> <p>Copies a string into an SV. The string must be null-terminated. Does not handle 'set' magic. See <code>sv_setpv_mg</code>.</p> <pre><code class="plaintext">void sv_setpv(SV* sv, const char* ptr)</code></pre> </dd> <dt id="sv_setpvf"><a class="permalink" href="#sv_setpvf">#</a>sv_setpvf</dt> <dd> <p>Processes its arguments like <code>sprintf</code> and sets an SV to the formatted output. Does not handle 'set' magic. See <code>sv_setpvf_mg</code>.</p> <pre><code class="plaintext">void sv_setpvf(SV* sv, const char* pat, ...)</code></pre> </dd> <dt id="sv_setpvf_mg"><a class="permalink" href="#sv_setpvf_mg">#</a>sv_setpvf_mg</dt> <dd> <p>Like <code>sv_setpvf</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setpvf_mg(SV *sv, const char* pat, ...)</code></pre> </dd> <dt id="sv_setpviv"><a class="permalink" href="#sv_setpviv">#</a>sv_setpviv</dt> <dd> <p>Copies an integer into the given SV, also updating its string value. Does not handle 'set' magic. See <code>sv_setpviv_mg</code>.</p> <pre><code class="plaintext">void sv_setpviv(SV* sv, IV num)</code></pre> </dd> <dt id="sv_setpviv_mg"><a class="permalink" href="#sv_setpviv_mg">#</a>sv_setpviv_mg</dt> <dd> <p>Like <code>sv_setpviv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setpviv_mg(SV *sv, IV iv)</code></pre> </dd> <dt id="sv_setpvn"><a class="permalink" href="#sv_setpvn">#</a>sv_setpvn</dt> <dd> <p>Copies a string into an SV. The <code>len</code> parameter indicates the number of bytes to be copied. Does not handle 'set' magic. See <code>sv_setpvn_mg</code>.</p> <pre><code class="plaintext">void sv_setpvn(SV* sv, const char* ptr, STRLEN len)</code></pre> </dd> <dt id="sv_setpvn_mg"><a class="permalink" href="#sv_setpvn_mg">#</a>sv_setpvn_mg</dt> <dd> <p>Like <code>sv_setpvn</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)</code></pre> </dd> <dt id="sv_setpv_mg"><a class="permalink" href="#sv_setpv_mg">#</a>sv_setpv_mg</dt> <dd> <p>Like <code>sv_setpv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setpv_mg(SV *sv, const char *ptr)</code></pre> </dd> <dt id="sv_setref_iv"><a class="permalink" href="#sv_setref_iv">#</a>sv_setref_iv</dt> <dd> <p>Copies an integer into a new SV, optionally blessing the SV. The <code>rv</code> argument will be upgraded to an RV. That RV will be modified to point to the new SV. The <code>classname</code> argument indicates the package for the blessing. Set <code>classname</code> to <code>Nullch</code> to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned.</p> <pre><code class="plaintext">SV* sv_setref_iv(SV* rv, const char* classname, IV iv)</code></pre> </dd> <dt id="sv_setref_nv"><a class="permalink" href="#sv_setref_nv">#</a>sv_setref_nv</dt> <dd> <p>Copies a double into a new SV, optionally blessing the SV. The <code>rv</code> argument will be upgraded to an RV. That RV will be modified to point to the new SV. The <code>classname</code> argument indicates the package for the blessing. Set <code>classname</code> to <code>Nullch</code> to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned.</p> <pre><code class="plaintext">SV* sv_setref_nv(SV* rv, const char* classname, NV nv)</code></pre> </dd> <dt id="sv_setref_pv"><a class="permalink" href="#sv_setref_pv">#</a>sv_setref_pv</dt> <dd> <p>Copies a pointer into a new SV, optionally blessing the SV. The <code>rv</code> argument will be upgraded to an RV. That RV will be modified to point to the new SV. If the <code>pv</code> argument is NULL then <code>PL_sv_undef</code> will be placed into the SV. The <code>classname</code> argument indicates the package for the blessing. Set <code>classname</code> to <code>Nullch</code> to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned.</p> <p>Do not use with other Perl types such as HV, AV, SV, CV, because those objects will become corrupted by the pointer copy process.</p> <p>Note that <code>sv_setref_pvn</code> copies the string while this copies the pointer.</p> <pre><code class="plaintext">SV* sv_setref_pv(SV* rv, const char* classname, void* pv)</code></pre> </dd> <dt id="sv_setref_pvn"><a class="permalink" href="#sv_setref_pvn">#</a>sv_setref_pvn</dt> <dd> <p>Copies a string into a new SV, optionally blessing the SV. The length of the string must be specified with <code>n</code>. The <code>rv</code> argument will be upgraded to an RV. That RV will be modified to point to the new SV. The <code>classname</code> argument indicates the package for the blessing. Set <code>classname</code> to <code>Nullch</code> to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned.</p> <p>Note that <code>sv_setref_pv</code> copies the pointer while this copies the string.</p> <pre><code class="plaintext">SV* sv_setref_pvn(SV* rv, const char* classname, char* pv, STRLEN n)</code></pre> </dd> <dt id="sv_setref_uv"><a class="permalink" href="#sv_setref_uv">#</a>sv_setref_uv</dt> <dd> <p>Copies an unsigned integer into a new SV, optionally blessing the SV. The <code>rv</code> argument will be upgraded to an RV. That RV will be modified to point to the new SV. The <code>classname</code> argument indicates the package for the blessing. Set <code>classname</code> to <code>Nullch</code> to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned.</p> <pre><code class="plaintext">SV* sv_setref_uv(SV* rv, const char* classname, UV uv)</code></pre> </dd> <dt id="sv_setsv"><a class="permalink" href="#sv_setsv">#</a>sv_setsv</dt> <dd> <p>Copies the contents of the source SV <code>ssv</code> into the destination SV <code>dsv</code>. The source SV may be destroyed if it is mortal, so don't use this function if the source SV needs to be reused. Does not handle 'set' magic. Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination.</p> <p>You probably want to use one of the assortment of wrappers, such as <code>SvSetSV</code>, <code>SvSetSV_nosteal</code>, <code>SvSetMagicSV</code> and <code>SvSetMagicSV_nosteal</code>.</p> <pre><code class="plaintext">void sv_setsv(SV* dsv, SV* ssv)</code></pre> </dd> <dt id="sv_setsv_flags"><a class="permalink" href="#sv_setsv_flags">#</a>sv_setsv_flags</dt> <dd> <p>Copies the contents of the source SV <code>ssv</code> into the destination SV <code>dsv</code>. The source SV may be destroyed if it is mortal, so don't use this function if the source SV needs to be reused. Does not handle 'set' magic. Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination. If the <code>flags</code> parameter has the <code>SV_GMAGIC</code> bit set, will <code>mg_get</code> on <code>ssv</code> if appropriate, else not. <code>sv_setsv</code> and <code>sv_setsv_nomg</code> are implemented in terms of this function.</p> <p>You probably want to use one of the assortment of wrappers, such as <code>SvSetSV</code>, <code>SvSetSV_nosteal</code>, <code>SvSetMagicSV</code> and <code>SvSetMagicSV_nosteal</code>.</p> <p>This is the primary function for copying scalars, and most other copy-ish functions and macros use this underneath.</p> <pre><code class="plaintext">void sv_setsv_flags(SV* dsv, SV* ssv, I32 flags)</code></pre> </dd> <dt id="sv_setsv_mg"><a class="permalink" href="#sv_setsv_mg">#</a>sv_setsv_mg</dt> <dd> <p>Like <code>sv_setsv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setsv_mg(SV *dstr, SV *sstr)</code></pre> </dd> <dt id="sv_setuv"><a class="permalink" href="#sv_setuv">#</a>sv_setuv</dt> <dd> <p>Copies an unsigned integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also <code>sv_setuv_mg</code>.</p> <pre><code class="plaintext">void sv_setuv(SV* sv, UV num)</code></pre> </dd> <dt id="sv_setuv_mg"><a class="permalink" href="#sv_setuv_mg">#</a>sv_setuv_mg</dt> <dd> <p>Like <code>sv_setuv</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_setuv_mg(SV *sv, UV u)</code></pre> </dd> <dt id="sv_taint"><a class="permalink" href="#sv_taint">#</a>sv_taint</dt> <dd> <p>Taint an SV. Use <code>SvTAINTED_on</code> instead. void sv_taint(SV* sv)</p> </dd> <dt id="sv_tainted"><a class="permalink" href="#sv_tainted">#</a>sv_tainted</dt> <dd> <p>Test an SV for taintedness. Use <code>SvTAINTED</code> instead. bool sv_tainted(SV* sv)</p> </dd> <dt id="sv_true"><a class="permalink" href="#sv_true">#</a>sv_true</dt> <dd> <p>Returns true if the SV has a true value by Perl's rules. Use the <code>SvTRUE</code> macro instead, which may call <code>sv_true()</code> or may instead use an in-line version.</p> <pre><code class="plaintext">I32 sv_true(SV *sv)</code></pre> </dd> <dt id="sv_unmagic"><a class="permalink" href="#sv_unmagic">#</a>sv_unmagic</dt> <dd> <p>Removes all magic of type <code>type</code> from an SV.</p> <pre><code class="plaintext">int sv_unmagic(SV* sv, int type)</code></pre> </dd> <dt id="sv_unref"><a class="permalink" href="#sv_unref">#</a>sv_unref</dt> <dd> <p>Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of as a reversal of <code>newSVrv</code>. This is <code>sv_unref_flags</code> with the <code>flag</code> being zero. See <code>SvROK_off</code>.</p> <pre><code class="plaintext">void sv_unref(SV* sv)</code></pre> </dd> <dt id="sv_unref_flags"><a class="permalink" href="#sv_unref_flags">#</a>sv_unref_flags</dt> <dd> <p>Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of as a reversal of <code>newSVrv</code>. The <code>cflags</code> argument can contain <code>SV_IMMEDIATE_UNREF</code> to force the reference count to be decremented (otherwise the decrementing is conditional on the reference count being different from one or the reference being a readonly SV). See <code>SvROK_off</code>.</p> <pre><code class="plaintext">void sv_unref_flags(SV* sv, U32 flags)</code></pre> </dd> <dt id="sv_untaint"><a class="permalink" href="#sv_untaint">#</a>sv_untaint</dt> <dd> <p>Untaint an SV. Use <code>SvTAINTED_off</code> instead. void sv_untaint(SV* sv)</p> </dd> <dt id="sv_upgrade"><a class="permalink" href="#sv_upgrade">#</a>sv_upgrade</dt> <dd> <p>Upgrade an SV to a more complex form. Generally adds a new body type to the SV, then copies across as much information as possible from the old body. You generally want to use the <code>SvUPGRADE</code> macro wrapper. See also <code>svtype</code>.</p> <pre><code class="plaintext">bool sv_upgrade(SV* sv, U32 mt)</code></pre> </dd> <dt id="sv_usepvn"><a class="permalink" href="#sv_usepvn">#</a>sv_usepvn</dt> <dd> <p>Tells an SV to use <code>ptr</code> to find its string value. Normally the string is stored inside the SV but sv_usepvn allows the SV to use an outside string. The <code>ptr</code> should point to memory that was allocated by <code>malloc</code>. The string length, <code>len</code>, must be supplied. This function will realloc the memory pointed to by <code>ptr</code>, so that pointer should not be freed or used by the programmer after giving it to sv_usepvn. Does not handle 'set' magic. See <code>sv_usepvn_mg</code>.</p> <pre><code class="plaintext">void sv_usepvn(SV* sv, char* ptr, STRLEN len)</code></pre> </dd> <dt id="sv_usepvn_mg"><a class="permalink" href="#sv_usepvn_mg">#</a>sv_usepvn_mg</dt> <dd> <p>Like <code>sv_usepvn</code>, but also handles 'set' magic.</p> <pre><code class="plaintext">void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)</code></pre> </dd> <dt id="sv_utf8_decode"><a class="permalink" href="#sv_utf8_decode">#</a>sv_utf8_decode</dt> <dd> <p>Convert the octets in the PV from UTF-8 to chars. Scan for validity and then turn off SvUTF8 if needed so that we see characters. Used as a building block for decode_utf8 in Encode.xs</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">bool sv_utf8_decode(SV *sv)</code></pre> </dd> <dt id="sv_utf8_downgrade"><a class="permalink" href="#sv_utf8_downgrade">#</a>sv_utf8_downgrade</dt> <dd> <p>Attempt to convert the PV of an SV from UTF-8-encoded to byte encoding. This may not be possible if the PV contains non-byte encoding characters; if this is the case, either returns false or, if <code>fail_ok</code> is not true, croaks.</p> <p>This is not as a general purpose Unicode to byte encoding interface: use the Encode extension for that.</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">bool sv_utf8_downgrade(SV *sv, bool fail_ok)</code></pre> </dd> <dt id="sv_utf8_encode"><a class="permalink" href="#sv_utf8_encode">#</a>sv_utf8_encode</dt> <dd> <p>Convert the PV of an SV to UTF-8-encoded, but then turn off the <code>SvUTF8</code> flag so that it looks like octets again. Used as a building block for encode_utf8 in Encode.xs</p> <pre><code class="plaintext">void sv_utf8_encode(SV *sv)</code></pre> </dd> <dt id="sv_utf8_upgrade"><a class="permalink" href="#sv_utf8_upgrade">#</a>sv_utf8_upgrade</dt> <dd> <p>Convert the PV of an SV to its UTF-8-encoded form. Forces the SV to string form if it is not already. Always sets the SvUTF8 flag to avoid future validity checks even if all the bytes have hibit clear.</p> <p>This is not as a general purpose byte encoding to Unicode interface: use the Encode extension for that.</p> <pre><code class="plaintext">STRLEN sv_utf8_upgrade(SV *sv)</code></pre> </dd> <dt id="sv_utf8_upgrade_flags"><a class="permalink" href="#sv_utf8_upgrade_flags">#</a>sv_utf8_upgrade_flags</dt> <dd> <p>Convert the PV of an SV to its UTF-8-encoded form. Forces the SV to string form if it is not already. Always sets the SvUTF8 flag to avoid future validity checks even if all the bytes have hibit clear. If <code>flags</code> has <code>SV_GMAGIC</code> bit set, will <code>mg_get</code> on <code>sv</code> if appropriate, else not. <code>sv_utf8_upgrade</code> and <code>sv_utf8_upgrade_nomg</code> are implemented in terms of this function.</p> <p>This is not as a general purpose byte encoding to Unicode interface: use the Encode extension for that.</p> <pre><code class="plaintext">STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags)</code></pre> </dd> <dt id="sv_uv"><a class="permalink" href="#sv_uv">#</a>sv_uv</dt> <dd> <p>A private implementation of the <code>SvUVx</code> macro for compilers which can't cope with complex macro expressions. Always use the macro instead.</p> <pre><code class="plaintext">UV sv_uv(SV* sv)</code></pre> </dd> <dt id="sv_vcatpvfn"><a class="permalink" href="#sv_vcatpvfn">#</a>sv_vcatpvfn</dt> <dd> <p>Processes its arguments like <code>vsprintf</code> and appends the formatted output to an SV. Uses an array of SVs if the C style variable argument list is missing (NULL). When running with taint checks enabled, indicates via <code>maybe_tainted</code> if results are untrustworthy (often due to the use of locales).</p> <p>Usually used via one of its frontends <code>sv_catpvf</code> and <code>sv_catpvf_mg</code>.</p> <pre><code class="plaintext">void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)</code></pre> </dd> <dt id="sv_vsetpvfn"><a class="permalink" href="#sv_vsetpvfn">#</a>sv_vsetpvfn</dt> <dd> <p>Works like <code>vcatpvfn</code> but copies the text into the SV instead of appending it.</p> <p>Usually used via one of its frontends <code>sv_setpvf</code> and <code>sv_setpvf_mg</code>.</p> <pre><code class="plaintext">void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)</code></pre> </dd> </dl> <h1 id="Unicode-Support"><a class="permalink" href="#Unicode-Support">#</a><a id="Unicode"></a>Unicode Support</h1> <dl> <dt id="bytes_from_utf8"><a class="permalink" href="#bytes_from_utf8">#</a>bytes_from_utf8</dt> <dd> <p>Converts a string <code>s</code> of length <code>len</code> from UTF-8 into byte encoding. Unlike <utf8_to_bytes> but like <code>bytes_to_utf8</code>, returns a pointer to the newly-created string, and updates <code>len</code> to contain the new length. Returns the original string if no conversion occurs, <code>len</code> is unchanged. Do nothing if <code>is_utf8</code> points to 0. Sets <code>is_utf8</code> to 0 if <code>s</code> is converted or contains all 7bit characters.</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">U8* bytes_from_utf8(U8 *s, STRLEN *len, bool *is_utf8)</code></pre> </dd> <dt id="bytes_to_utf8"><a class="permalink" href="#bytes_to_utf8">#</a>bytes_to_utf8</dt> <dd> <p>Converts a string <code>s</code> of length <code>len</code> from ASCII into UTF-8 encoding. Returns a pointer to the newly-created string, and sets <code>len</code> to reflect the new length.</p> <p>If you want to convert to UTF-8 from other encodings than ASCII, see sv_recode_to_utf8().</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">U8* bytes_to_utf8(U8 *s, STRLEN *len)</code></pre> </dd> <dt id="ibcmp_utf8"><a class="permalink" href="#ibcmp_utf8">#</a>ibcmp_utf8</dt> <dd> <p>Return true if the strings s1 and s2 differ case-insensitively, false if not (if they are equal case-insensitively). If u1 is true, the string s1 is assumed to be in UTF-8-encoded Unicode. If u2 is true, the string s2 is assumed to be in UTF-8-encoded Unicode. If u1 or u2 are false, the respective string is assumed to be in native 8-bit encoding.</p> <p>If the pe1 and pe2 are non-NULL, the scanning pointers will be copied in there (they will point at the beginning of the <i>next</i> character). If the pointers behind pe1 or pe2 are non-NULL, they are the end pointers beyond which scanning will not continue under any circustances. If the byte lengths l1 and l2 are non-zero, s1+l1 and s2+l2 will be used as goal end pointers that will also stop the scan, and which qualify towards defining a successful match: all the scans that define an explicit length must reach their goal pointers for a match to succeed).</p> <p>For case-insensitiveness, the "casefolding" of Unicode is used instead of upper/lowercasing both the characters, see http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).</p> <pre><code class="plaintext">I32 ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2)</code></pre> </dd> <dt id="is_utf8_char"><a class="permalink" href="#is_utf8_char">#</a>is_utf8_char</dt> <dd> <p>Tests if some arbitrary number of bytes begins in a valid UTF-8 character. Note that an INVARIANT (i.e. ASCII) character is a valid UTF-8 character. The actual number of bytes in the UTF-8 character will be returned if it is valid, otherwise 0.</p> <pre><code class="plaintext">STRLEN is_utf8_char(U8 *p)</code></pre> </dd> <dt id="is_utf8_string"><a class="permalink" href="#is_utf8_string">#</a>is_utf8_string</dt> <dd> <p>Returns true if first <code>len</code> bytes of the given string form a valid UTF-8 string, false otherwise. Note that 'a valid UTF-8 string' does not mean 'a string that contains code points above 0x7F encoded in UTF-8' because a valid ASCII string is a valid UTF-8 string.</p> <pre><code class="plaintext">bool is_utf8_string(U8 *s, STRLEN len)</code></pre> </dd> <dt id="is_utf8_string_loc"><a class="permalink" href="#is_utf8_string_loc">#</a>is_utf8_string_loc</dt> <dd> <p>Like is_ut8_string but store the location of the failure in the last argument.</p> <pre><code class="plaintext">bool is_utf8_string_loc(U8 *s, STRLEN len, U8 **p)</code></pre> </dd> <dt id="pv_uni_display"><a class="permalink" href="#pv_uni_display">#</a>pv_uni_display</dt> <dd> <p>Build to the scalar dsv a displayable version of the string spv, length len, the displayable version being at most pvlim bytes long (if longer, the rest is truncated and "..." will be appended).</p> <p>The flags argument can have UNI_DISPLAY_ISPRINT set to display isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH to display the \\[nrfta\\] as the backslashed versions (like '\n') (UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\). UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.</p> <p>The pointer to the PV of the dsv is returned.</p> <pre><code class="plaintext">char* pv_uni_display(SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags)</code></pre> </dd> <dt id="sv_cat_decode"><a class="permalink" href="#sv_cat_decode">#</a>sv_cat_decode</dt> <dd> <p>The encoding is assumed to be an Encode object, the PV of the ssv is assumed to be octets in that encoding and decoding the input starts from the position which (PV + *offset) pointed to. The dsv will be concatenated the decoded UTF-8 string from ssv. Decoding will terminate when the string tstr appears in decoding output or the input ends on the PV of the ssv. The value which the offset points will be modified to the last input position on the ssv.</p> <p>Returns TRUE if the terminator was found, else returns FALSE.</p> <pre><code class="plaintext">bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen)</code></pre> </dd> <dt id="sv_recode_to_utf8"><a class="permalink" href="#sv_recode_to_utf8">#</a>sv_recode_to_utf8</dt> <dd> <p>The encoding is assumed to be an Encode object, on entry the PV of the sv is assumed to be octets in that encoding, and the sv will be converted into Unicode (and UTF-8).</p> <p>If the sv already is UTF-8 (or if it is not POK), or if the encoding is not a reference, nothing is done to the sv. If the encoding is not an <code>Encode::XS</code> Encoding object, bad things will happen. (See <i>lib/encoding.pm</i> and <a href="/5.8.1/Encode">Encode</a>).</p> <p>The PV of the sv is returned.</p> <pre><code class="plaintext">char* sv_recode_to_utf8(SV* sv, SV *encoding)</code></pre> </dd> <dt id="sv_uni_display"><a class="permalink" href="#sv_uni_display">#</a>sv_uni_display</dt> <dd> <p>Build to the scalar dsv a displayable version of the scalar sv, the displayable version being at most pvlim bytes long (if longer, the rest is truncated and "..." will be appended).</p> <p>The flags argument is as in pv_uni_display().</p> <p>The pointer to the PV of the dsv is returned.</p> <pre><code class="plaintext">char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)</code></pre> </dd> <dt id="to_utf8_case"><a class="permalink" href="#to_utf8_case">#</a>to_utf8_case</dt> <dd> <p>The "p" contains the pointer to the UTF-8 string encoding the character that is being converted.</p> <p>The "ustrp" is a pointer to the character buffer to put the conversion result to. The "lenp" is a pointer to the length of the result.</p> <p>The "swashp" is a pointer to the swash to use.</p> <p>Both the special and normal mappings are stored lib/unicore/To/Foo.pl, and loaded by SWASHGET, using lib/utf8_heavy.pl. The special (usually, but not always, a multicharacter mapping), is tried first.</p> <p>The "special" is a string like "utf8::ToSpecLower", which means the hash %utf8::ToSpecLower. The access to the hash is through Perl_to_utf8_case().</p> <p>The "normal" is a string like "ToLower" which means the swash %utf8::ToLower.</p> <pre><code class="plaintext">UV to_utf8_case(U8 *p, U8* ustrp, STRLEN *lenp, SV **swash, char *normal, char *special)</code></pre> </dd> <dt id="to_utf8_fold"><a class="permalink" href="#to_utf8_fold">#</a>to_utf8_fold</dt> <dd> <p>Convert the UTF-8 encoded character at p to its foldcase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note that the ustrp needs to be at least UTF8_MAXLEN_FOLD+1 bytes since the foldcase version may be longer than the original character (up to three characters).</p> <p>The first character of the foldcased version is returned (but note, as explained above, that there may be more.)</p> <pre><code class="plaintext">UV to_utf8_fold(U8 *p, U8* ustrp, STRLEN *lenp)</code></pre> </dd> <dt id="to_utf8_lower"><a class="permalink" href="#to_utf8_lower">#</a>to_utf8_lower</dt> <dd> <p>Convert the UTF-8 encoded character at p to its lowercase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the lowercase version may be longer than the original character (up to two characters).</p> <p>The first character of the lowercased version is returned (but note, as explained above, that there may be more.)</p> <pre><code class="plaintext">UV to_utf8_lower(U8 *p, U8* ustrp, STRLEN *lenp)</code></pre> </dd> <dt id="to_utf8_title"><a class="permalink" href="#to_utf8_title">#</a>to_utf8_title</dt> <dd> <p>Convert the UTF-8 encoded character at p to its titlecase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the titlecase version may be longer than the original character (up to two characters).</p> <p>The first character of the titlecased version is returned (but note, as explained above, that there may be more.)</p> <pre><code class="plaintext">UV to_utf8_title(U8 *p, U8* ustrp, STRLEN *lenp)</code></pre> </dd> <dt id="to_utf8_upper"><a class="permalink" href="#to_utf8_upper">#</a>to_utf8_upper</dt> <dd> <p>Convert the UTF-8 encoded character at p to its uppercase version and store that in UTF-8 in ustrp and its length in bytes in lenp. Note that the ustrp needs to be at least UTF8_MAXLEN_UCLC+1 bytes since the uppercase version may be longer than the original character (up to two characters).</p> <p>The first character of the uppercased version is returned (but note, as explained above, that there may be more.)</p> <pre><code class="plaintext">UV to_utf8_upper(U8 *p, U8* ustrp, STRLEN *lenp)</code></pre> </dd> <dt id="utf8n_to_uvchr"><a class="permalink" href="#utf8n_to_uvchr">#</a>utf8n_to_uvchr</dt> <dd> <p>Returns the native character value of the first character in the string <code>s</code> which is assumed to be in UTF-8 encoding; <code>retlen</code> will be set to the length, in bytes, of that character.</p> <p>Allows length and flags to be passed to low level routine.</p> <pre><code class="plaintext">UV utf8n_to_uvchr(U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags)</code></pre> </dd> <dt id="utf8n_to_uvuni"><a class="permalink" href="#utf8n_to_uvuni">#</a>utf8n_to_uvuni</dt> <dd> <p>Bottom level UTF-8 decode routine. Returns the unicode code point value of the first character in the string <code>s</code> which is assumed to be in UTF-8 encoding and no longer than <code>curlen</code>; <code>retlen</code> will be set to the length, in bytes, of that character.</p> <p>If <code>s</code> does not point to a well-formed UTF-8 character, the behaviour is dependent on the value of <code>flags</code>: if it contains UTF8_CHECK_ONLY, it is assumed that the caller will raise a warning, and this function will silently just set <code>retlen</code> to <code>-1</code> and return zero. If the <code>flags</code> does not contain UTF8_CHECK_ONLY, warnings about malformations will be given, <code>retlen</code> will be set to the expected length of the UTF-8 character in bytes, and zero will be returned.</p> <p>The <code>flags</code> can also contain various flags to allow deviations from the strict UTF-8 encoding (see <i>utf8.h</i>).</p> <p>Most code should use utf8_to_uvchr() rather than call this directly.</p> <pre><code class="plaintext">UV utf8n_to_uvuni(U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags)</code></pre> </dd> <dt id="utf8_distance"><a class="permalink" href="#utf8_distance">#</a>utf8_distance</dt> <dd> <p>Returns the number of UTF-8 characters between the UTF-8 pointers <code>a</code> and <code>b</code>.</p> <p>WARNING: use only if you *know* that the pointers point inside the same UTF-8 buffer.</p> <pre><code class="plaintext">IV utf8_distance(U8 *a, U8 *b)</code></pre> </dd> <dt id="utf8_hop"><a class="permalink" href="#utf8_hop">#</a>utf8_hop</dt> <dd> <p>Return the UTF-8 pointer <code>s</code> displaced by <code>off</code> characters, either forward or backward.</p> <p>WARNING: do not use the following unless you *know* <code>off</code> is within the UTF-8 data pointed to by <code>s</code> *and* that on entry <code>s</code> is aligned on the first byte of character or just after the last byte of a character.</p> <pre><code class="plaintext">U8* utf8_hop(U8 *s, I32 off)</code></pre> </dd> <dt id="utf8_length"><a class="permalink" href="#utf8_length">#</a>utf8_length</dt> <dd> <p>Return the length of the UTF-8 char encoded string <code>s</code> in characters. Stops at <code>e</code> (inclusive). If <code>e < s</code> or if the scan would end up past <code>e</code>, croaks.</p> <pre><code class="plaintext">STRLEN utf8_length(U8* s, U8 *e)</code></pre> </dd> <dt id="utf8_to_bytes"><a class="permalink" href="#utf8_to_bytes">#</a>utf8_to_bytes</dt> <dd> <p>Converts a string <code>s</code> of length <code>len</code> from UTF-8 into byte encoding. Unlike <code>bytes_to_utf8</code>, this over-writes the original string, and updates len to contain the new length. Returns zero on failure, setting <code>len</code> to -1.</p> <p>NOTE: this function is experimental and may change or be removed without notice.</p> <pre><code class="plaintext">U8* utf8_to_bytes(U8 *s, STRLEN *len)</code></pre> </dd> <dt id="utf8_to_uvchr"><a class="permalink" href="#utf8_to_uvchr">#</a>utf8_to_uvchr</dt> <dd> <p>Returns the native character value of the first character in the string <code>s</code> which is assumed to be in UTF-8 encoding; <code>retlen</code> will be set to the length, in bytes, of that character.</p> <p>If <code>s</code> does not point to a well-formed UTF-8 character, zero is returned and retlen is set, if possible, to -1.</p> <pre><code class="plaintext">UV utf8_to_uvchr(U8 *s, STRLEN* retlen)</code></pre> </dd> <dt id="utf8_to_uvuni"><a class="permalink" href="#utf8_to_uvuni">#</a>utf8_to_uvuni</dt> <dd> <p>Returns the Unicode code point of the first character in the string <code>s</code> which is assumed to be in UTF-8 encoding; <code>retlen</code> will be set to the length, in bytes, of that character.</p> <p>This function should only be used when returned UV is considered an index into the Unicode semantic tables (e.g. swashes).</p> <p>If <code>s</code> does not point to a well-formed UTF-8 character, zero is returned and retlen is set, if possible, to -1.</p> <pre><code class="plaintext">UV utf8_to_uvuni(U8 *s, STRLEN* retlen)</code></pre> </dd> <dt id="uvchr_to_utf8"><a class="permalink" href="#uvchr_to_utf8">#</a>uvchr_to_utf8</dt> <dd> <p>Adds the UTF-8 representation of the Native codepoint <code>uv</code> to the end of the string <code>d</code>; <code>d</code> should be have at least <code>UTF8_MAXLEN+1</code> free bytes available. The return value is the pointer to the byte after the end of the new character. In other words,</p> <pre><code>d = uvchr_to_utf8(d, uv);</code></pre> <p>is the recommended wide native character-aware way of saying</p> <pre><code> *(d++) = uv; U8* uvchr_to_utf8(U8 *d, UV uv)</code></pre> </dd> <dt id="uvuni_to_utf8_flags"><a class="permalink" href="#uvuni_to_utf8_flags">#</a>uvuni_to_utf8_flags</dt> <dd> <p>Adds the UTF-8 representation of the Unicode codepoint <code>uv</code> to the end of the string <code>d</code>; <code>d</code> should be have at least <code>UTF8_MAXLEN+1</code> free bytes available. The return value is the pointer to the byte after the end of the new character. In other words,</p> <pre><code>d = uvuni_to_utf8_flags(d, uv, flags);</code></pre> <p>or, in most cases,</p> <pre><code>d = uvuni_to_utf8(d, uv);</code></pre> <p>(which is equivalent to)</p> <pre><code>d = uvuni_to_utf8_flags(d, uv, 0);</code></pre> <p>is the recommended Unicode-aware way of saying</p> <pre><code> *(d++) = uv; U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)</code></pre> </dd> </dl> <h1 id="Variables-created-by-xsubpp-and-xsubpp-internal-functions"><a class="permalink" href="#Variables-created-by-xsubpp-and-xsubpp-internal-functions">#</a><a id="Variables"></a>Variables created by <code>xsubpp</code> and <code>xsubpp</code> internal functions</h1> <dl> <dt id="ax"><a class="permalink" href="#ax">#</a>ax</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to indicate the stack base offset, used by the <code>ST</code>, <code>XSprePUSH</code> and <code>XSRETURN</code> macros. The <code>dMARK</code> macro must be called prior to setup the <code>MARK</code> variable.</p> <pre><code class="plaintext">I32 ax</code></pre> </dd> <dt id="CLASS"><a class="permalink" href="#CLASS">#</a>CLASS</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to indicate the class name for a C++ XS constructor. This is always a <code>char*</code>. See <code>THIS</code>.</p> <pre><code class="plaintext">char* CLASS</code></pre> </dd> <dt id="dAX"><a class="permalink" href="#dAX">#</a>dAX</dt> <dd> <p>Sets up the <code>ax</code> variable. This is usually handled automatically by <code>xsubpp</code> by calling <code>dXSARGS</code>.</p> <pre><code>dAX;</code></pre> </dd> <dt id="dITEMS"><a class="permalink" href="#dITEMS">#</a>dITEMS</dt> <dd> <p>Sets up the <code>items</code> variable. This is usually handled automatically by <code>xsubpp</code> by calling <code>dXSARGS</code>.</p> <pre><code>dITEMS;</code></pre> </dd> <dt id="dXSARGS"><a class="permalink" href="#dXSARGS">#</a>dXSARGS</dt> <dd> <p>Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. Sets up the <code>ax</code> and <code>items</code> variables by calling <code>dAX</code> and <code>dITEMS</code>. This is usually handled automatically by <code>xsubpp</code>.</p> <pre><code>dXSARGS;</code></pre> </dd> <dt id="dXSI32"><a class="permalink" href="#dXSI32">#</a>dXSI32</dt> <dd> <p>Sets up the <code>ix</code> variable for an XSUB which has aliases. This is usually handled automatically by <code>xsubpp</code>.</p> <pre><code>dXSI32;</code></pre> </dd> <dt id="items"><a class="permalink" href="#items">#</a>items</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to indicate the number of items on the stack. See <a href="/5.8.1/perlxs#Variable-length-Parameter-Lists">"Variable-length Parameter Lists" in perlxs</a>.</p> <pre><code class="plaintext">I32 items</code></pre> </dd> <dt id="ix"><a class="permalink" href="#ix">#</a>ix</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to indicate which of an XSUB's aliases was used to invoke it. See <a href="/5.8.1/perlxs#The-ALIAS%3A-Keyword">"The ALIAS: Keyword" in perlxs</a>.</p> <pre><code class="plaintext">I32 ix</code></pre> </dd> <dt id="newXSproto"><a class="permalink" href="#newXSproto">#</a>newXSproto</dt> <dd> <p>Used by <code>xsubpp</code> to hook up XSUBs as Perl subs. Adds Perl prototypes to the subs.</p> </dd> <dt id="RETVAL"><a class="permalink" href="#RETVAL">#</a>RETVAL</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to hold the return value for an XSUB. This is always the proper type for the XSUB. See <a href="/5.8.1/perlxs#The-RETVAL-Variable">"The RETVAL Variable" in perlxs</a>.</p> <pre><code class="plaintext">(whatever) RETVAL</code></pre> </dd> <dt id="ST"><a class="permalink" href="#ST">#</a>ST</dt> <dd> <p>Used to access elements on the XSUB's stack.</p> <pre><code class="plaintext">SV* ST(int ix)</code></pre> </dd> <dt id="THIS"><a class="permalink" href="#THIS">#</a>THIS</dt> <dd> <p>Variable which is setup by <code>xsubpp</code> to designate the object in a C++ XSUB. This is always the proper type for the C++ object. See <code>CLASS</code> and <a href="/5.8.1/perlxs#Using-XS-With-C%2B%2B">"Using XS With C++" in perlxs</a>.</p> <pre><code class="plaintext">(whatever) THIS</code></pre> </dd> <dt id="XS"><a class="permalink" href="#XS">#</a>XS</dt> <dd> <p>Macro to declare an XSUB and its C parameter list. This is handled by <code>xsubpp</code>.</p> </dd> <dt id="XSRETURN_EMPTY"><a class="permalink" href="#XSRETURN_EMPTY">#</a>XSRETURN_EMPTY</dt> <dd> <p>Return an empty list from an XSUB immediately.</p> <pre><code>XSRETURN_EMPTY;</code></pre> </dd> <dt id="XS_VERSION"><a class="permalink" href="#XS_VERSION">#</a>XS_VERSION</dt> <dd> <p>The version identifier for an XS module. This is usually handled automatically by <code>ExtUtils::MakeMaker</code>. See <code>XS_VERSION_BOOTCHECK</code>.</p> </dd> <dt id="XS_VERSION_BOOTCHECK"><a class="permalink" href="#XS_VERSION_BOOTCHECK">#</a>XS_VERSION_BOOTCHECK</dt> <dd> <p>Macro to verify that a PM module's $VERSION variable matches the XS module's <code>XS_VERSION</code> variable. This is usually handled automatically by <code>xsubpp</code>. See <a href="/5.8.1/perlxs#The-VERSIONCHECK%3A-Keyword">"The VERSIONCHECK: Keyword" in perlxs</a>.</p> <pre><code>XS_VERSION_BOOTCHECK;</code></pre> </dd> </dl> <h1 id="Warning-and-Dieing"><a class="permalink" href="#Warning-and-Dieing">#</a><a id="Warning"></a>Warning and Dieing</h1> <dl> <dt id="croak"><a class="permalink" href="#croak">#</a>croak</dt> <dd> <p>This is the XSUB-writer's interface to Perl's <code>die</code> function. Normally use this function the same way you use the C <code>printf</code> function. See <code>warn</code>.</p> <p>If you want to throw an exception object, assign the object to <code>$@</code> and then pass <code>Nullch</code> to croak():</p> <pre><code> errsv = get_sv("@", TRUE); sv_setsv(errsv, exception_object); croak(Nullch); void croak(const char* pat, ...)</code></pre> </dd> <dt id="warn"><a class="permalink" href="#warn">#</a>warn</dt> <dd> <p>This is the XSUB-writer's interface to Perl's <code>warn</code> function. Use this function the same way you use the C <code>printf</code> function. See <code>croak</code>.</p> <pre><code class="plaintext">void warn(const char* pat, ...)</code></pre> </dd> </dl> <h1 id="AUTHORS"><a class="permalink" href="#AUTHORS">#</a>AUTHORS</h1> <p>Until May 1997, this document was maintained by Jeff Okamoto <okamoto@corp.hp.com>. It is now maintained as part of Perl itself.</p> <p>With lots of help and suggestions from Dean Roehrich, Malcolm Beattie, Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer, Stephen McCamant, and Gurusamy Sarathy.</p> <p>API Listing originally by Dean Roehrich <roehrich@cray.com>.</p> <p>Updated to be autogenerated from comments in the source by Benjamin Stuhl.</p> <h1 id="SEE-ALSO"><a class="permalink" href="#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1> <p>perlguts(1), perlxs(1), perlxstut(1), perlintern(1)</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>