📄 perlapi.pod
字号:
=item sv_usepvnX<sv_usepvn>Tells an SV to use C<ptr> to find its string value. Implemented bycalling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'magic. See C<sv_usepvn_flags>. void sv_usepvn(SV* sv, char* ptr, STRLEN len)=for hackersFound in file mathoms.c=item sv_usepvn_mgX<sv_usepvn_mg>Like C<sv_usepvn>, but also handles 'set' magic. void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)=for hackersFound in file mathoms.c=item sv_uvX<sv_uv>A private implementation of the C<SvUVx> macro for compilers which can'tcope with complex macro expressions. Always use the macro instead. UV sv_uv(SV* sv)=for hackersFound in file mathoms.c=item unpack_strX<unpack_str>The engine implementing unpack() Perl function. Note: parameters strbeg, new_sand ocnt are not used. This call should not be used, use unpackstring instead. I32 unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags)=for hackersFound in file mathoms.c=back=head1 Functions in file pp_ctl.c=over 8=item find_runcvX<find_runcv>Locate the CV corresponding to the currently executing sub or eval.If db_seqp is non_null, skip CVs that are in the DB package and populate*db_seqp with the cop sequence number at the point that the DB:: code wasentered. (allows debuggers to eval in the scope of the breakpoint ratherthan in the scope of the debugger itself). CV* find_runcv(U32 *db_seqp)=for hackersFound in file pp_ctl.c=back=head1 Functions in file pp_pack.c=over 8=item packlistX<packlist>The engine implementing pack() Perl function. void packlist(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist)=for hackersFound in file pp_pack.c=item unpackstringX<unpackstring>The engine implementing unpack() Perl function. C<unpackstring> puts theextracted list items on the stack and returns the number of elements.Issue C<PUTBACK> before and C<SPAGAIN> after the call to this function. I32 unpackstring(const char *pat, const char *patend, const char *s, const char *strend, U32 flags)=for hackersFound in file pp_pack.c=back=head1 GV Functions=over 8=item GvSVX<GvSV>Return the SV from the GV. SV* GvSV(GV* gv)=for hackersFound in file gv.h=item gv_const_svX<gv_const_sv>If C<gv> is a typeglob whose subroutine entry is a constant sub eligible forinlining, or C<gv> is a placeholder reference that would be promoted to sucha typeglob, then returns the value returned by the sub. Otherwise, returnsNULL. SV* gv_const_sv(GV* gv)=for hackersFound in file gv.c=item gv_fetchmethX<gv_fetchmeth>Returns the glob with the given C<name> and a defined subroutine orC<NULL>. The glob lives in the given C<stash>, or in the stashesaccessible via @ISA and UNIVERSAL::.The argument C<level> should be either 0 or -1. If C<level==0>, as aside-effect creates a glob with the given C<name> in the given C<stash>which in the case of success contains an alias for the subroutine, and setsup caching info for this glob.This function grants C<"SUPER"> token as a postfix of the stash name. TheGV returned from C<gv_fetchmeth> may be a method cache entry, which is notvisible to Perl code. So when calling C<call_sv>, you should not usethe GV directly; instead, you should use the method's CV, which can beobtained from the GV with the C<GvCV> macro. GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)=for hackersFound in file gv.c=item gv_fetchmethod_autoloadX<gv_fetchmethod_autoload>Returns the glob which contains the subroutine to call to invoke the methodon the C<stash>. In fact in the presence of autoloading this may be theglob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD isalready setup.The third parameter of C<gv_fetchmethod_autoload> determines whetherAUTOLOAD lookup is performed if the given method is not present: non-zeromeans yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD.Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload>with a non-zero C<autoload> parameter.These functions grant C<"SUPER"> token as a prefix of the method name. Notethat if you want to keep the returned glob for a long time, you need tocheck for it being "AUTOLOAD", since at the later time the call may load adifferent subroutine due to $AUTOLOAD changing its value. Use the globcreated via a side effect to do this.These functions have the same side-effects and as C<gv_fetchmeth> withC<level==0>. C<name> should be writable if contains C<':'> or C<'''>. The warning against passing the GV returned by C<gv_fetchmeth> toC<call_sv> apply equally to these functions. GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)=for hackersFound in file gv.c=item gv_fetchmeth_autoloadX<gv_fetchmeth_autoload>Same as gv_fetchmeth(), but looks for autoloaded subroutines too.Returns a glob for the subroutine.For an autoloaded subroutine without a GV, will create a GV evenif C<level < 0>. For an autoloaded subroutine without a stub, GvCV()of the result may be zero. GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)=for hackersFound in file gv.c=item gv_stashpvX<gv_stashpv>Returns a pointer to the stash for a specified package. Uses C<strlen> todetermine the length of C<name>, then calls C<gv_stashpvn()>. HV* gv_stashpv(const char* name, I32 flags)=for hackersFound in file gv.c=item gv_stashpvnX<gv_stashpvn>Returns a pointer to the stash for a specified package. The C<namelen>parameter indicates the length of the C<name>, in bytes. C<flags> is passedto C<gv_fetchpvn_flags()>, so if set to C<GV_ADD> then the package will becreated if it does not already exist. If the package does not exist andC<flags> is 0 (or any other setting that does not create packages) then NULLis returned. HV* gv_stashpvn(const char* name, U32 namelen, I32 flags)=for hackersFound in file gv.c=item gv_stashpvsX<gv_stashpvs>Like C<gv_stashpvn>, but takes a literal string instead of a string/length pair. HV* gv_stashpvs(const char* name, I32 create)=for hackersFound in file handy.h=item gv_stashsvX<gv_stashsv>Returns a pointer to the stash for a specified package. See C<gv_stashpvn>. HV* gv_stashsv(SV* sv, I32 flags)=for hackersFound in file gv.c=back=head1 Handy Values=over 8=item NullavX<Nullav>Null AV pointer.=for hackersFound in file av.h=item NullchX<Nullch>Null character pointer.=for hackersFound in file handy.h=item NullcvX<Nullcv>Null CV pointer.=for hackersFound in file cv.h=item NullhvX<Nullhv>Null HV pointer.=for hackersFound in file hv.h=item NullsvX<Nullsv>Null SV pointer.=for hackersFound in file handy.h=back=head1 Hash Manipulation Functions=over 8=item get_hvX<get_hv>Returns the HV of the specified Perl hash. If C<create> is set and thePerl variable does not exist then it will be created. If C<create> is notset and the variable does not exist then NULL is returned.NOTE: the perl_ form of this function is deprecated. HV* get_hv(const char* name, I32 create)=for hackersFound in file perl.c=item HEf_SVKEYX<HEf_SVKEY>This flag, used in the length slot of hash entries and magic structures,specifies the structure contains an C<SV*> pointer where a C<char*> pointeris to be expected. (For information only--not to be used).=for hackersFound in file hv.h=item HeHASHX<HeHASH>Returns the computed hash stored in the hash entry. U32 HeHASH(HE* he)=for hackersFound in file hv.h=item HeKEYX<HeKEY>Returns the actual pointer stored in the key slot of the hash entry. Thepointer may be either C<char*> or C<SV*>, depending on the value ofC<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros areusually preferable for finding the value of a key. void* HeKEY(HE* he)=for hackersFound in file hv.h=item HeKLENX<HeKLEN>If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entryholds an C<SV*> key. Otherwise, holds the actual length of the key. Canbe assigned to. The C<HePV()> macro is usually preferable for finding keylengths. STRLEN HeKLEN(HE* he)=for hackersFound in file hv.h=item HePVX<HePV>Returns the key slot of the hash entry as a C<char*> value, doing anynecessary dereferencing of possibly C<SV*> keys. The length of the stringis placed in C<len> (this is a macro, so do I<not> use C<&len>). If you donot care about what the length of the key is, you may use the globalvariable C<PL_na>, though this is rather less efficient than using a localvariable. Remember though, that hash keys in perl are free to containembedded nulls, so using C<strlen()> or similar is not a good way to findthe length of hash keys. This is very similar to the C<SvPV()> macrodescribed elsewhere in this document. char* HePV(HE* he, STRLEN len)=for hackersFound in file hv.h=item HeSVKEYX<HeSVKEY>Returns the key as an C<SV*>, or C<NULL> if the hash entry does notcontain an C<SV*> key. SV* HeSVKEY(HE* he)=for hackersFound in file hv.h=item HeSVKEY_forceX<HeSVKEY_force>Returns the key as an C<SV*>. Will create and return a temporary mortalC<SV*> if the hash entry contains only a C<char*> key. SV* HeSVKEY_force(HE* he)=for hackersFound in file hv.h=item HeSVKEY_setX<HeSVKEY_set>Sets the key to a given C<SV*>, taking care to set the appropriate flags toindicate the presence of an C<SV*> key, and returns the sameC<SV*>. SV* HeSVKEY_set(HE* he, SV* sv)=for hackersFound in file hv.h=item HeVALX<HeVAL>Returns the value slot (type C<SV*>) stored in the hash entry. SV* HeVAL(HE* he)=for hackersFound in file hv.h=item HvNAMEX<HvNAME>Returns the package name of a stash, or NULL if C<stash> isn't a stash.See C<SvSTASH>, C<CvSTASH>. char* HvNAME(HV* stash)=for hackersFound in file hv.h=item hv_assertX<hv_assert>Check that a hash is in an internally consistent state. void hv_assert(HV* tb)=for hackersFound in file hv.c=item hv_clearX<hv_clear>Clears a hash, making it empty. void hv_clear(HV* tb)=for hackersFound in file hv.c=item hv_clear_placeholdersX<hv_clear_placeholders>Clears any placeholders from a hash. If a restricted hash has any of its keysmarked as readonly and the key is subsequently deleted, the key is not actuallydeleted but is marked by assigning it a value of &PL_sv_placeholder. This tagsit so it will be ignored by future operations such as iterating over the hash,but will still allow the hash to have a value reassigned to the key at somefuture point. This function clears any such placeholder keys from the hash.See Hash::Util::lock_keys() for an example of its use. void hv_clear_placeholders(HV* hb)=for hackersFound in file hv.c=item hv_deleteX<hv_delete>Deletes a key/value pair in the hash. The value SV is removed from thehash and returned to the caller. The C<klen> is the length of the key.The C<flags> value will normally be zero; if set to G_DISCARD then NULLwill be returned. SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)=for hackersFound in file hv.c=item hv_delete_entX<hv_delete_ent>Deletes a key/value pair in the hash. The value SV is removed from thehash and returned to the caller. The C<flags> value will normally be zero;if set to G_DISCARD then NULL will be returned. C<hash> can be a validprecomputed hash value, or 0 to ask for it to be computed. SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)=for hackersFound in file hv.c=item hv_existsX<hv_exists>Returns a boolean indicating whether the specified hash key exists. TheC<klen> is the length of the key. bool hv_exists(HV* tb, const char* key, I32 klen)=for hackersFound in file hv.c=item hv_exists_entX<hv_exists_ent>Returns a boolean indicating whether the specified hash key exists. C<hash>can be a valid precomputed hash value, or 0 to ask for it to becomputed. bool hv_exists_ent(HV* tb, SV* key, U32 hash)=for hackersFound in file hv.c=item hv_fetchX<hv_fetch>Returns the SV which corresponds to the specified key in the hash. TheC<klen> is the length of the key. If C<lval> is set then the fetch will bepart of a store. Check that the return value is non-null beforedereferencing it to an C<SV*>.See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for moreinformation on how to use this function on tied hashes. SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)=for hackersFound in file hv.c=item hv_fetchsX<hv_fetchs>Like C<hv_fetch>, but takes a literal string instead of a string/length pair. SV** hv_fetchs(HV* tb, const char* key, I32 lval)=for hackersFound in file handy.h=item hv_fetch_entX<hv_fetch_ent>Returns the hash entry which corresponds to the specified key in the hash.C<hash> must be a valid precomputed hash number for the given C<key>, or 0if you want the function to compute it. IF C<lval> is set then the fetchwill be part of a store. Make sure the return value is non-null beforeaccessing it. The return value when C<tb> is a tied hash is a pointer to astatic location, so be sure to make a copy of the structure if you need tostore it somewhere.See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for moreinformation on how to use this function on tied hashes. HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)=for hackersFound in file hv.c=item hv_iterinitX<hv_iterinit>Prepares a starting point to traverse a hash table. Returns the number ofkeys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value iscurrently only meaningful for hashes without tie magic.NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number ofhash buckets that happen to be in use. If you still need that esotericvalue, you can get it through the macro C<HvFILL(tb)>. I32 hv_iterinit(HV* tb)=for hackersFound in file hv.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -