-*- buffer-read-only: t -*-
!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
This file is built by autodoc.pl extracting documentation from the C source
files.
Any changes made here will be lost!
=encoding UTF-8
=head1 NAME
perlapi - autogenerated documentation for the perl public API
=head1 DESCRIPTION
X X X
This file contains most of the documentation of the perl public API, as
generated by F. Specifically, it is a listing of functions,
macros, flags, and variables that may be used by extension writers. Some
specialized items are instead documented in F, L, L, L, L, L, L, L, L, and L.
L is a list of functions which have yet
to be documented. Patches welcome! The interfaces of these are subject to
change without notice.
Anything not listed here is not part of the public API, and should not be
used by extension writers at all. For these reasons, blindly using functions
listed in proto.h is to be avoided when writing extensions.
In Perl, unlike C, a string of characters may generally contain embedded
C characters. Sometimes in the documentation a Perl string is referred
to as a "buffer" to distinguish it from a C string, but sometimes they are
both just referred to as strings.
Note that all Perl API global variables must be referenced with the C
prefix. Again, those not listed here are not to be used by extension writers,
and can be changed or removed without notice; same with macros.
Some macros are provided for compatibility with the older,
unadorned names, but this support may be disabled in a future release.
Perl was originally written to handle US-ASCII only (that is characters
whose ordinal numbers are in the range 0 - 127).
And documentation and comments may still use the term ASCII, when
sometimes in fact the entire range from 0 - 255 is meant.
The non-ASCII characters below 256 can have various meanings, depending on
various things. (See, most notably, L.) But usually the whole
range can be referred to as ISO-8859-1. Often, the term "Latin-1" (or
"Latin1") is used as an equivalent for ISO-8859-1. But some people treat
"Latin1" as referring just to the characters in the range 128 through 255, or
somethimes from 160 through 255.
This documentation uses "Latin1" and "Latin-1" to refer to all 256 characters.
Note that Perl can be compiled and run under either ASCII or EBCDIC (See
L). Most of the documentation (and even comments in the code)
ignore the EBCDIC possibility.
For almost all purposes the differences are transparent.
As an example, under EBCDIC,
instead of UTF-8, UTF-EBCDIC is used to encode Unicode strings, and so
whenever this documentation refers to C
(and variants of that name, including in function names),
it also (essentially transparently) means C.
But the ordinals of characters differ between ASCII, EBCDIC, and
the UTF- encodings, and a string encoded in UTF-EBCDIC may occupy a different
number of bytes than in UTF-8.
The listing below is alphabetical, case insensitive.
=head1 Array Manipulation Functions
=over 8
=item av_clear
X
Frees the all the elements of an array, leaving it empty.
The XS equivalent of C<@array = ()>. See also L.
Note that it is possible that the actions of a destructor called directly
or indirectly by freeing an element of the array could cause the reference
count of the array itself to be reduced (e.g. by deleting an entry in the
symbol table). So it is a possibility that the AV could have been freed
(or even reallocated) on return from the call unless you hold a reference
to it.
void av_clear(AV *av)
=for hackers
Found in file av.c
=item av_create_and_push
X
NOTE: this function is experimental and may change or be
removed without notice.
Push an SV onto the end of the array, creating the array if necessary.
A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function must be explicitly called as Perl_av_create_and_push with an aTHX_ parameter.
void Perl_av_create_and_push(pTHX_ AV **const avp,
SV *const val)
=for hackers
Found in file av.c
=item av_create_and_unshift_one
X
NOTE: this function is experimental and may change or be
removed without notice.
Unshifts an SV onto the beginning of the array, creating the array if
necessary.
A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function must be explicitly called as Perl_av_create_and_unshift_one with an aTHX_ parameter.
SV** Perl_av_create_and_unshift_one(pTHX_
AV **const avp,
SV *const val)
=for hackers
Found in file av.c
=item av_delete
X
Deletes the element indexed by C from the array, makes the element
mortal, and returns it. If C equals C, the element is
freed and NULL is returned. NULL is also returned if C is out of
range.
Perl equivalent: S> (with the
C in void context if C is present).
SV* av_delete(AV *av, SSize_t key, I32 flags)
=for hackers
Found in file av.c
=item av_exists
X
Returns true if the element indexed by C has been initialized.
This relies on the fact that uninitialized array elements are set to
C.
Perl equivalent: C.
bool av_exists(AV *av, SSize_t key)
=for hackers
Found in file av.c
=item av_extend
X
Pre-extend an array so that it is capable of storing values at indexes
C<0..key>. Thus C guarantees that the array can store 100
elements, i.e. that C through C
on a plain array will work without any further memory allocation.
If the av argument is a tied array then will call the C tied
array method with an argument of C<(key+1)>.
void av_extend(AV *av, SSize_t key)
=for hackers
Found in file av.c
=item av_fetch
X
Returns the SV at the specified index in the array. The C is the
index. If lval is true, you are guaranteed to get a real SV back (in case
it wasn't real before), which you can then modify. Check that the return
value is non-null before dereferencing it to a C.
See L for
more information on how to use this function on tied arrays.
The rough perl equivalent is C<$myarray[$key]>.
SV** av_fetch(AV *av, SSize_t key, I32 lval)
=for hackers
Found in file av.c
=item AvFILL
X
Same as C or C.
int AvFILL(AV* av)
=for hackers
Found in file av.h
=item av_fill
X
Set the highest index in the array to the given number, equivalent to
Perl's S>.
The number of elements in the array will be S> after
C returns. If the array was previously shorter, then the
additional elements appended are set to NULL. If the array
was longer, then the excess elements are freed. S> is
the same as C.
void av_fill(AV *av, SSize_t fill)
=for hackers
Found in file av.c
=item av_len
X
Same as L. Note that, unlike what the name implies, it returns
the highest index in the array. This is unlike L, which returns what
you would expect.
B>>.
SSize_t av_len(AV *av)
=for hackers
Found in file av.c
=item av_make
X
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 C. The new AV
will have a reference count of 1.
Perl equivalent: C
AV* av_make(SSize_t size, SV **strp)
=for hackers
Found in file av.c
=item av_pop
X
Removes one SV from the end of the array, reducing its size by one and
returning the SV (transferring control of one reference count) to the
caller. Returns C<&PL_sv_undef> if the array is empty.
Perl equivalent: C
SV* av_pop(AV *av)
=for hackers
Found in file av.c
=item av_push
X
Pushes an SV (transferring control of one reference count) onto the end of the
array. The array will grow automatically to accommodate the addition.
Perl equivalent: C.
void av_push(AV *av, SV *val)
=for hackers
Found in file av.c
=item av_shift
X
Removes one SV from the start of the array, reducing its size by one and
returning the SV (transferring control of one reference count) to the
caller. Returns C<&PL_sv_undef> if the array is empty.
Perl equivalent: C
SV* av_shift(AV *av)
=for hackers
Found in file av.c
=item av_store
X
Stores an SV in an array. The array index is specified as C. The
return value will be C 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 C that was stored
there (= C)).
Note that the caller is responsible for suitably incrementing the reference
count of C before the call, and decrementing it if the function
returned C.
Approximate Perl equivalent: C.
See L for
more information on how to use this function on tied arrays.
SV** av_store(AV *av, SSize_t key, SV *val)
=for hackers
Found in file av.c
=item av_tindex
X
Same as C.
SSize_t av_tindex(AV *av)
=for hackers
Found in file av.h
=item av_top_index
X
Returns the highest index in the array. The number of elements in the
array is S>. Returns -1 if the array is empty.
The Perl equivalent for this is C<$#myarray>.
(A slightly shorter form is C.)
SSize_t av_top_index(AV *av)
=for hackers
Found in file av.c
=item av_undef
X
Undefines the array. The XS equivalent of C.
As well as freeing all the elements of the array (like C), this
also frees the memory used by the av to store its list of scalars.
See L for a note about the array possibly being invalid on
return.
void av_undef(AV *av)
=for hackers
Found in file av.c
=item av_unshift
X
Unshift the given number of C values onto the beginning of the
array. The array will grow automatically to accommodate the addition.
Perl equivalent: S>
void av_unshift(AV *av, SSize_t num)
=for hackers
Found in file av.c
=item get_av
X
Returns the AV of the specified Perl global or package array with the given
name (so it won't work on lexical variables). C are passed
to C. If C is set and the
Perl variable does not exist then it will be created. If C is zero
and the variable does not exist then NULL is returned.
Perl equivalent: C<@{"$name"}>.
NOTE: the perl_ form of this function is deprecated.
AV* get_av(const char *name, I32 flags)
=for hackers
Found in file perl.c
=item newAV
X
Creates a new AV. The reference count is set to 1.
Perl equivalent: C.
AV* newAV()
=for hackers
Found in file av.h
=item sortsv
X
In-place sort an array of SV pointers with the given comparison routine.
Currently this always uses mergesort. See C> for a more
flexible routine.
void sortsv(SV** array, size_t num_elts,
SVCOMPARE_t cmp)
=for hackers
Found in file pp_sort.c
=back
=head1 Callback Functions
=over 8
=item call_argv
X
Performs a callback to the specified named and package-scoped Perl subroutine
with C (a C-terminated array of strings) as arguments. See
L.
Approximate Perl equivalent: C<&{"$sub_name"}(@$argv)>.
NOTE: the perl_ form of this function is deprecated.
I32 call_argv(const char* sub_name, I32 flags,
char** argv)
=for hackers
Found in file perl.c
=item call_method
X
Performs a callback to the specified Perl method. The blessed object must
be on the stack. See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_method(const char* methname, I32 flags)
=for hackers
Found in file perl.c
=item call_pv
X
Performs a callback to the specified Perl sub. See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_pv(const char* sub_name, I32 flags)
=for hackers
Found in file perl.c
=item call_sv
X
Performs a callback to the Perl sub specified by the SV.
If neither the C nor C flag is supplied, the
SV may be any of a CV, a GV, a reference to a CV, a reference to a GV
or C will be used as the name of the sub to call.
If the C flag is supplied, the SV may be a reference to a CV or
C will be used as the name of the method to call.
If the C flag is supplied, C will be used as
the name of the method to call.
Some other values are treated specially for internal use and should
not be depended on.
See L.
NOTE: the perl_ form of this function is deprecated.
I32 call_sv(SV* sv, volatile I32 flags)
=for hackers
Found in file perl.c
=item ENTER
X
Opening bracket on a callback. See C> and L.
ENTER;
=for hackers
Found in file scope.h
=item ENTER_with_name
X
Same as C>, but when debugging is enabled it also associates the
given literal string with the new scope.
ENTER_with_name("name");
=for hackers
Found in file scope.h
=item eval_pv
X
Tells Perl to C the given string in scalar context and return an SV* result.
NOTE: the perl_ form of this function is deprecated.
SV* eval_pv(const char* p, I32 croak_on_error)
=for hackers
Found in file perl.c
=item eval_sv
X
Tells Perl to C the string in the SV. It supports the same flags
as C, with the obvious exception of C. See L.
The C flag can be used if you only need eval_sv() to
execute code specified by a string, but not catch any errors.
NOTE: the perl_ form of this function is deprecated.
I32 eval_sv(SV* sv, I32 flags)
=for hackers
Found in file perl.c
=item FREETMPS
X
Closing bracket for temporaries on a callback. See C> and
L.
FREETMPS;
=for hackers
Found in file scope.h
=item LEAVE
X
Closing bracket on a callback. See C> and L.
LEAVE;
=for hackers
Found in file scope.h
=item LEAVE_with_name
X
Same as C>, but when debugging is enabled it first checks that the
scope has the given name. C must be a literal string.
LEAVE_with_name("name");
=for hackers
Found in file scope.h
=item SAVETMPS
X
Opening bracket for temporaries on a callback. See C> and
L.
SAVETMPS;
=for hackers
Found in file scope.h
=back
=head1 Character case changing
Perl uses "full" Unicode case mappings. This means that converting a single
character to another case may result in a sequence of more than one character.
For example, the uppercase of C> (LATIN SMALL LETTER SHARP S) is the two
character sequence C. This presents some complications The lowercase of
all characters in the range 0..255 is a single character, and thus
C> is furnished. But, C can't exist, as it couldn't
return a valid result for all legal inputs. Instead C> has
an API that does allow every possible legal result to be returned.) Likewise
no other function that is crippled by not being able to give the correct
results for the full range of possible inputs has been implemented here.
=over 8
=item toFOLD
X
Converts the specified character to foldcase. If the input is anything but an
ASCII uppercase character, that input character itself is returned. Variant
C is equivalent. (There is no equivalent C for the full
Latin1 range, as the full generality of L is needed there.)
U8 toFOLD(U8 ch)
=for hackers
Found in file handy.h
=item toFOLD_utf8
X
Converts the first UTF-8 encoded character in the sequence starting at C and
extending no further than S> to its foldcase version, and
stores that in UTF-8 in C, and its length in bytes in C. Note
that the buffer pointed to by C needs to be at least C
bytes since the foldcase version may be longer than the original character.
The first code point of the foldcased version is returned
(but note, as explained at L, that there may be more).
It will not attempt
to read beyond S>, provided that the constraint S e>> is
true (this is asserted for in C<-DDEBUGGING> builds). If the UTF-8 for the
input character is malformed in some way, the program may croak, or the
function may return the REPLACEMENT CHARACTER, at the discretion of the
implementation, and subject to change in future releases.
UV toFOLD_utf8(U8* p, U8* e, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toFOLD_utf8_safe
X
Same as L
.
UV toFOLD_utf8_safe(U8* p, U8* e, U8* s,
STRLEN* lenp)
=for hackers
Found in file handy.h
=item toFOLD_uvchr
X
Converts the code point C to its foldcase version, and
stores that in UTF-8 in C, and its length in bytes in C. The code
point is interpreted as native if less than 256; otherwise as Unicode. Note
that the buffer pointed to by C needs to be at least C
bytes since the foldcase version may be longer than the original character.
The first code point of the foldcased version is returned
(but note, as explained at L, that there may be more).
UV toFOLD_uvchr(UV cp, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toLOWER
X
Converts the specified character to lowercase. If the input is anything but an
ASCII uppercase character, that input character itself is returned. Variant
C is equivalent.
U8 toLOWER(U8 ch)
=for hackers
Found in file handy.h
=item toLOWER_L1
X
Converts the specified Latin1 character to lowercase. The results are
undefined if the input doesn't fit in a byte.
U8 toLOWER_L1(U8 ch)
=for hackers
Found in file handy.h
=item toLOWER_LC
X
Converts the specified character to lowercase using the current locale's rules,
if possible; otherwise returns the input character itself.
U8 toLOWER_LC(U8 ch)
=for hackers
Found in file handy.h
=item toLOWER_utf8
X
Converts the first UTF-8 encoded character in the sequence starting at C and
extending no further than S> to its lowercase version, and
stores that in UTF-8 in C, and its length in bytes in C. Note
that the buffer pointed to by C needs to be at least C
bytes since the lowercase version may be longer than the original character.
The first code point of the lowercased version is returned
(but note, as explained at L, that there may be more).
It will not attempt to read beyond S>, provided that the constraint
S e>> is true (this is asserted for in C<-DDEBUGGING> builds). If
the UTF-8 for the input character is malformed in some way, the program may
croak, or the function may return the REPLACEMENT CHARACTER, at the discretion
of the implementation, and subject to change in future releases.
UV toLOWER_utf8(U8* p, U8* e, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toLOWER_utf8_safe
X
Same as L
.
UV toLOWER_utf8_safe(U8* p, U8* e, U8* s,
STRLEN* lenp)
=for hackers
Found in file handy.h
=item toLOWER_uvchr
X
Converts the code point C to its lowercase version, and
stores that in UTF-8 in C, and its length in bytes in C. The code
point is interpreted as native if less than 256; otherwise as Unicode. Note
that the buffer pointed to by C needs to be at least C
bytes since the lowercase version may be longer than the original character.
The first code point of the lowercased version is returned
(but note, as explained at L, that there may be more).
UV toLOWER_uvchr(UV cp, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toTITLE
X
Converts the specified character to titlecase. If the input is anything but an
ASCII lowercase character, that input character itself is returned. Variant
C is equivalent. (There is no C for the full Latin1
range, as the full generality of L is needed there. Titlecase is
not a concept used in locale handling, so there is no functionality for that.)
U8 toTITLE(U8 ch)
=for hackers
Found in file handy.h
=item toTITLE_utf8
X
Converts the first UTF-8 encoded character in the sequence starting at C and
extending no further than S> to its titlecase version, and
stores that in UTF-8 in C, and its length in bytes in C. Note
that the buffer pointed to by C needs to be at least C
bytes since the titlecase version may be longer than the original character.
The first code point of the titlecased version is returned
(but note, as explained at L, that there may be more).
It will not attempt
to read beyond S>, provided that the constraint S e>> is
true (this is asserted for in C<-DDEBUGGING> builds). If the UTF-8 for the
input character is malformed in some way, the program may croak, or the
function may return the REPLACEMENT CHARACTER, at the discretion of the
implementation, and subject to change in future releases.
UV toTITLE_utf8(U8* p, U8* e, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toTITLE_utf8_safe
X
Same as L
.
UV toTITLE_utf8_safe(U8* p, U8* e, U8* s,
STRLEN* lenp)
=for hackers
Found in file handy.h
=item toTITLE_uvchr
X
Converts the code point C to its titlecase version, and
stores that in UTF-8 in C, and its length in bytes in C. The code
point is interpreted as native if less than 256; otherwise as Unicode. Note
that the buffer pointed to by C needs to be at least C
bytes since the titlecase version may be longer than the original character.
The first code point of the titlecased version is returned
(but note, as explained at L, that there may be more).
UV toTITLE_uvchr(UV cp, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toUPPER
X
Converts the specified character to uppercase. If the input is anything but an
ASCII lowercase character, that input character itself is returned. Variant
C is equivalent.
U8 toUPPER(int ch)
=for hackers
Found in file handy.h
=item toUPPER_utf8
X
Converts the first UTF-8 encoded character in the sequence starting at C and
extending no further than S> to its uppercase version, and
stores that in UTF-8 in C, and its length in bytes in C. Note
that the buffer pointed to by C needs to be at least C
bytes since the uppercase version may be longer than the original character.
The first code point of the uppercased version is returned
(but note, as explained at L, that there may be more).
It will not attempt to read beyond S>, provided that the constraint
S e>> is true (this is asserted for in C<-DDEBUGGING> builds). If
the UTF-8 for the input character is malformed in some way, the program may
croak, or the function may return the REPLACEMENT CHARACTER, at the discretion
of the implementation, and subject to change in future releases.
UV toUPPER_utf8(U8* p, U8* e, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item toUPPER_utf8_safe
X
Same as L
.
UV toUPPER_utf8_safe(U8* p, U8* e, U8* s,
STRLEN* lenp)
=for hackers
Found in file handy.h
=item toUPPER_uvchr
X
Converts the code point C to its uppercase version, and
stores that in UTF-8 in C, and its length in bytes in C. The code
point is interpreted as native if less than 256; otherwise as Unicode. Note
that the buffer pointed to by C needs to be at least C
bytes since the uppercase version may be longer than the original character.
The first code point of the uppercased version is returned
(but note, as explained at L, that there may be more.)
UV toUPPER_uvchr(UV cp, U8* s, STRLEN* lenp)
=for hackers
Found in file handy.h
=item WIDEST_UTYPE
X
Yields the widest unsigned integer type on the platform, currently either
C or C<64>. This can be used in declarations such as
WIDEST_UTYPE my_uv;
or casts
my_uv = (WIDEST_UTYPE) val;
=for hackers
Found in file handy.h
=back
=head1 Character classification
This section is about functions (really macros) that classify characters
into types, such as punctuation versus alphabetic, etc. Most of these are
analogous to regular expression character classes. (See
L.) There are several variants for
each class. (Not all macros have all variants; each item below lists the
ones valid for it.) None are affected by C