📄 b.html
字号:
<dd>
<p>Returns a double-quote-surrounded escaped version of STR which can
be used as a string in Perl source code.</p>
</dd>
</li>
<dt><strong><a name="item_class"><code>class(OBJ)</code></a></strong>
<dd>
<p>Returns the class of an object without the part of the classname
preceding the first <code>"::"</code>. This is used to turn <code>"B::UNOP"</code> into
<code>"UNOP"</code> for example.</p>
</dd>
</li>
<dt><strong><a name="item_threadsv_names">threadsv_names</a></strong>
<dd>
<p>In a perl compiled for threads, this returns a list of the special
per-thread threadsv variables.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="overview_of_classes">OVERVIEW OF CLASSES</a></h1>
<p>The C structures used by Perl's internals to hold SV and OP
information (PVIV, AV, HV, ..., OP, SVOP, UNOP, ...) are modelled on a
class hierarchy and the <code>B</code> module gives access to them via a true
object hierarchy. Structure fields which point to other objects
(whether types of SV or types of OP) are represented by the <code>B</code>
module as Perl objects of the appropriate class.</p>
<p>The bulk of the <code>B</code> module is the methods for accessing fields of
these structures.</p>
<p>Note that all access is read-only. You cannot modify the internals by
using this module. Also, note that the B::OP and B::SV objects created
by this module are only valid for as long as the underlying objects
exist; their creation doesn't increase the reference counts of the
underlying objects. Trying to access the fields of a freed object will
give incomprehensible results, or worse.</p>
<p>
</p>
<h2><a name="svrelated_classes">SV-RELATED CLASSES</a></h2>
<p>B::IV, B::NV, B::RV, B::PV, B::PVIV, B::PVNV, B::PVMG, B::BM, B::PVLV,
B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes correspond in
the obvious way to the underlying C structures of similar names. The
inheritance hierarchy mimics the underlying C "inheritance". For 5.9.1
and later this is:</p>
<pre>
B::SV
|
+--------------+----------+------------+
| | | |
B::PV B::IV B::NV B::RV
\ / /
\ / /
B::PVIV /
\ /
\ /
\ /
B::PVNV
|
|
B::PVMG
|
+-----+----+------+-----+-----+
| | | | | |
B::BM B::AV B::GV B::HV B::CV B::IO
| |
B::PVLV |
B::FM</pre>
<p>For 5.9.0 and earlier, PVLV is a direct subclass of PVMG, so the base
of this diagram is</p>
<pre>
|
B::PVMG
|
+------+-----+----+------+-----+-----+
| | | | | | |
B::PVLV B::BM B::AV B::GV B::HV B::CV B::IO
|
|
B::FM</pre>
<p>Access methods correspond to the underlying C macros for field access,
usually with the leading "class indication" prefix removed (Sv, Av,
Hv, ...). The leading prefix is only left in cases where its removal
would cause a clash in method name. For example, <a href="#item_gvrefcnt"><code>GvREFCNT</code></a> stays
as-is since its abbreviation would clash with the "superclass" method
<a href="#item_refcnt"><code>REFCNT</code></a> (corresponding to the C function <code>SvREFCNT</code>).</p>
<p>
</p>
<h2><a name="b__sv_methods">B::SV Methods</a></h2>
<dl>
<dt><strong><a name="item_refcnt">REFCNT</a></strong>
<dt><strong><a name="item_flags">FLAGS</a></strong>
<dt><strong><a name="item_object_2svref">object_2svref</a></strong>
<dd>
<p>Returns a reference to the regular scalar corresponding to this
B::SV object. In other words, this method is the inverse operation
to the <a href="#item_svref_2object"><code>svref_2object()</code></a> subroutine. This scalar and other data it points
at should be considered read-only: modifying them is neither safe nor
guaranteed to have a sensible effect.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="b__iv_methods">B::IV Methods</a></h2>
<dl>
<dt><strong><a name="item_iv">IV</a></strong>
<dd>
<p>Returns the value of the IV, <em>interpreted as
a signed integer</em>. This will be misleading
if <code>FLAGS & SVf_IVisUV</code>. Perhaps you want the
<a href="#item_int_value"><code>int_value</code></a> method instead?</p>
</dd>
</li>
<dt><strong><a name="item_ivx">IVX</a></strong>
<dt><strong><a name="item_uvx">UVX</a></strong>
<dt><strong><a name="item_int_value">int_value</a></strong>
<dd>
<p>This method returns the value of the IV as an integer.
It differs from <a href="#item_iv"><code>IV</code></a> in that it returns the correct
value regardless of whether it's stored signed or
unsigned.</p>
</dd>
</li>
<dt><strong><a name="item_needs64bits">needs64bits</a></strong>
<dt><strong><a name="item_packiv">packiv</a></strong>
</dl>
<p>
</p>
<h2><a name="b__nv_methods">B::NV Methods</a></h2>
<dl>
<dt><strong><a name="item_nv">NV</a></strong>
<dt><strong><a name="item_nvx">NVX</a></strong>
</dl>
<p>
</p>
<h2><a name="b__rv_methods">B::RV Methods</a></h2>
<dl>
<dt><strong><a name="item_rv">RV</a></strong>
</dl>
<p>
</p>
<h2><a name="b__pv_methods">B::PV Methods</a></h2>
<dl>
<dt><strong><a name="item_pv">PV</a></strong>
<dd>
<p>This method is the one you usually want. It constructs a
string using the length and offset information in the struct:
for ordinary scalars it will return the string that you'd see
from Perl, even if it contains null characters.</p>
</dd>
</li>
<dt><strong>RV</strong>
<dd>
<p>Same as B::RV::RV, except that it will <a href="../lib/Pod/perlfunc.html#item_die"><code>die()</code></a> if the PV isn't
a reference.</p>
</dd>
</li>
<dt><strong><a name="item_pvx">PVX</a></strong>
<dd>
<p>This method is less often useful. It assumes that the string
stored in the struct is null-terminated, and disregards the
length information.</p>
</dd>
<dd>
<p>It is the appropriate method to use if you need to get the name
of a lexical variable from a padname array. Lexical variable names
are always stored with a null terminator, and the length field
(SvCUR) is overloaded for other purposes and can't be relied on here.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="b__pvmg_methods">B::PVMG Methods</a></h2>
<dl>
<dt><strong><a name="item_magic">MAGIC</a></strong>
<dt><strong><a name="item_svstash">SvSTASH</a></strong>
</dl>
<p>
</p>
<h2><a name="b__magic_methods">B::MAGIC Methods</a></h2>
<dl>
<dt><strong><a name="item_moremagic">MOREMAGIC</a></strong>
<dt><strong><a name="item_precomp">precomp</a></strong>
<dd>
<p>Only valid on r-magic, returns the string that generated the regexp.</p>
</dd>
</li>
<dt><strong><a name="item_private">PRIVATE</a></strong>
<dt><strong><a name="item_type">TYPE</a></strong>
<dt><strong>FLAGS</strong>
<dt><strong><a name="item_obj">OBJ</a></strong>
<dd>
<p>Will <a href="../lib/Pod/perlfunc.html#item_die"><code>die()</code></a> if called on r-magic.</p>
</dd>
</li>
<dt><strong><a name="item_ptr">PTR</a></strong>
<dt><strong><a name="item_regex">REGEX</a></strong>
<dd>
<p>Only valid on r-magic, returns the integer value of the REGEX stored
in the MAGIC.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="b__pvlv_methods">B::PVLV Methods</a></h2>
<dl>
<dt><strong><a name="item_targoff">TARGOFF</a></strong>
<dt><strong><a name="item_targlen">TARGLEN</a></strong>
<dt><strong>TYPE</strong>
<dt><strong><a name="item_targ">TARG</a></strong>
</dl>
<p>
</p>
<h2><a name="b__bm_methods">B::BM Methods</a></h2>
<dl>
<dt><strong><a name="item_useful">USEFUL</a></strong>
<dt><strong><a name="item_previous">PREVIOUS</a></strong>
<dt><strong><a name="item_rare">RARE</a></strong>
<dt><strong><a name="item_table">TABLE</a></strong>
</dl>
<p>
</p>
<h2><a name="b__gv_methods">B::GV Methods</a></h2>
<dl>
<dt><strong><a name="item_is_empty">is_empty</a></strong>
<dd>
<p>This method returns TRUE if the GP field of the GV is NULL.</p>
</dd>
</li>
<dt><strong><a name="item_name">NAME</a></strong>
<dt><strong><a name="item_safename">SAFENAME</a></strong>
<dd>
<p>This method returns the name of the glob, but if the first
character of the name is a control character, then it converts
it to ^X first, so that *^G would return "^G" rather than "\cG".</p>
</dd>
<dd>
<p>It's useful if you want to print out the name of a variable.
If you restrict yourself to globs which exist at compile-time
then the result ought to be unambiguous, because code like
<code>${"^G"} = 1</code> is compiled as two ops - a constant string and
a dereference (rv2gv) - so that the glob is created at runtime.</p>
</dd>
<dd>
<p>If you're working with globs at runtime, and need to disambiguate
*^G from *{"^G"}, then you should use the raw NAME method.</p>
</dd>
</li>
<dt><strong><a name="item_stash">STASH</a></strong>
<dt><strong><a name="item_sv">SV</a></strong>
<dt><strong><a name="item_io">IO</a></strong>
<dt><strong><a name="item_form">FORM</a></strong>
<dt><strong><a name="item_av">AV</a></strong>
<dt><strong><a name="item_hv">HV</a></strong>
<dt><strong><a name="item_egv">EGV</a></strong>
<dt><strong><a name="item_cv">CV</a></strong>
<dt><strong><a name="item_cvgen">CVGEN</a></strong>
<dt><strong><a name="item_line">LINE</a></strong>
<dt><strong><a name="item_file">FILE</a></strong>
<dt><strong><a name="item_filegv">FILEGV</a></strong>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -