perlguts.html

来自「perl教程」· HTML 代码 · 共 790 行 · 第 1/5 页

HTML
790
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>perlguts - Introduction to the Perl API</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>perlguts - Introduction to the Perl API</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#variables">Variables</a></li>
	<ul>

		<li><a href="#datatypes">Datatypes</a></li>
		<li><a href="#what_is_an_iv">What is an &quot;IV&quot;?</a></li>
		<li><a href="#working_with_svs">Working with SVs</a></li>
		<li><a href="#offsets">Offsets</a></li>
		<li><a href="#what_s_really_stored_in_an_sv">What's Really Stored in an SV?</a></li>
		<li><a href="#working_with_avs">Working with AVs</a></li>
		<li><a href="#working_with_hvs">Working with HVs</a></li>
		<li><a href="#hash_api_extensions">Hash API Extensions</a></li>
		<li><a href="#avs__hvs_and_undefined_values">AVs, HVs and undefined values</a></li>
		<li><a href="#references">References</a></li>
		<li><a href="#blessed_references_and_class_objects">Blessed References and Class Objects</a></li>
		<li><a href="#creating_new_variables">Creating New Variables</a></li>
		<li><a href="#reference_counts_and_mortality">Reference Counts and Mortality</a></li>
		<li><a href="#stashes_and_globs">Stashes and Globs</a></li>
		<li><a href="#doubletyped_svs">Double-Typed SVs</a></li>
		<li><a href="#magic_variables">Magic Variables</a></li>
		<li><a href="#assigning_magic">Assigning Magic</a></li>
		<li><a href="#magic_virtual_tables">Magic Virtual Tables</a></li>
		<li><a href="#finding_magic">Finding Magic</a></li>
		<li><a href="#understanding_the_magic_of_tied_hashes_and_arrays">Understanding the Magic of Tied Hashes and Arrays</a></li>
		<li><a href="#localizing_changes">Localizing changes</a></li>
	</ul>

	<li><a href="#subroutines">Subroutines</a></li>
	<ul>

		<li><a href="#xsubs_and_the_argument_stack">XSUBs and the Argument Stack</a></li>
		<li><a href="#calling_perl_routines_from_within_c_programs">Calling Perl Routines from within C Programs</a></li>
		<li><a href="#memory_allocation">Memory Allocation</a></li>
		<ul>

			<li><a href="#allocation">Allocation</a></li>
			<li><a href="#reallocation">Reallocation</a></li>
			<li><a href="#moving">Moving</a></li>
		</ul>

		<li><a href="#perlio">PerlIO</a></li>
		<li><a href="#putting_a_c_value_on_perl_stack">Putting a C value on Perl stack</a></li>
		<li><a href="#scratchpads">Scratchpads</a></li>
		<li><a href="#scratchpads_and_recursion">Scratchpads and recursion</a></li>
	</ul>

	<li><a href="#compiled_code">Compiled code</a></li>
	<ul>

		<li><a href="#code_tree">Code tree</a></li>
		<li><a href="#examining_the_tree">Examining the tree</a></li>
		<li><a href="#compile_pass_1__check_routines">Compile pass 1: check routines</a></li>
		<li><a href="#compile_pass_1a__constant_folding">Compile pass 1a: constant folding</a></li>
		<li><a href="#compile_pass_2__context_propagation">Compile pass 2: context propagation</a></li>
		<li><a href="#compile_pass_3__peephole_optimization">Compile pass 3: peephole optimization</a></li>
		<li><a href="#pluggable_runops">Pluggable runops</a></li>
	</ul>

	<li><a href="#examining_internal_data_structures_with_the_dump_functions">Examining internal data structures with the <a href="../../lib/Pod/perlfunc.html#item_dump"><code>dump</code></a> functions</a></li>
	<li><a href="#how_multiple_interpreters_and_concurrency_are_supported">How multiple interpreters and concurrency are supported</a></li>
	<ul>

		<li><a href="#background_and_perl_implicit_context">Background and PERL_IMPLICIT_CONTEXT</a></li>
		<li><a href="#so_what_happened_to_dthr">So what happened to dTHR?</a></li>
		<li><a href="#how_do_i_use_all_this_in_extensions">How do I use all this in extensions?</a></li>
		<li><a href="#should_i_do_anything_special_if_i_call_perl_from_multiple_threads">Should I do anything special if I call perl from multiple threads?</a></li>
		<li><a href="#future_plans_and_perl_implicit_sys">Future Plans and PERL_IMPLICIT_SYS</a></li>
	</ul>

	<li><a href="#internal_functions">Internal Functions</a></li>
	<ul>

		<li><a href="#formatted_printing_of_ivs__uvs__and_nvs">Formatted Printing of IVs, UVs, and NVs</a></li>
		<li><a href="#pointertointeger_and_integertopointer">Pointer-To-Integer and Integer-To-Pointer</a></li>
		<li><a href="#source_documentation">Source Documentation</a></li>
		<li><a href="#backwards_compatibility">Backwards compatibility</a></li>
	</ul>

	<li><a href="#unicode_support">Unicode Support</a></li>
	<ul>

		<li><a href="#what_is_unicode__anyway">What <strong>is</strong> Unicode, anyway?</a></li>
		<li><a href="#how_can_i_recognise_a_utf8_string">How can I recognise a UTF-8 string?</a></li>
		<li><a href="#how_does_utf8_represent_unicode_characters">How does UTF-8 represent Unicode characters?</a></li>
		<li><a href="#how_does_perl_store_utf8_strings">How does Perl store UTF-8 strings?</a></li>
		<li><a href="#how_do_i_convert_a_string_to_utf8">How do I convert a string to UTF-8?</a></li>
		<li><a href="#is_there_anything_else_i_need_to_know">Is there anything else I need to know?</a></li>
	</ul>

	<li><a href="#custom_operators">Custom Operators</a></li>
	<li><a href="#authors">AUTHORS</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>perlguts - Introduction to the Perl API</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This document attempts to describe how to use the Perl API, as well as
to provide some info on the basic workings of the Perl core. It is far
from complete and probably contains many errors. Please refer any
questions or comments to the author below.</p>
<p>
</p>
<hr />
<h1><a name="variables">Variables</a></h1>
<p>
</p>
<h2><a name="datatypes">Datatypes</a></h2>
<p>Perl has three typedefs that handle Perl's three main data types:</p>
<pre>
    SV  Scalar Value
    AV  Array Value
    HV  Hash Value</pre>
<p>Each typedef has specific routines that manipulate the various data types.</p>
<p>
</p>
<h2><a name="what_is_an_iv">What is an &quot;IV&quot;?</a></h2>
<p>Perl uses a special typedef IV which is a simple signed integer type that is
guaranteed to be large enough to hold a pointer (as well as an integer).
Additionally, there is the UV, which is simply an unsigned IV.</p>
<p>Perl also uses two special typedefs, I32 and I16, which will always be at
least 32-bits and 16-bits long, respectively. (Again, there are U32 and U16,
as well.)  They will usually be exactly 32 and 16 bits long, but on Crays
they will both be 64 bits.</p>
<p>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?