⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devel::peek.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
\&          FLAGS = (IOK,pIOK)\&          IV = 42.Ve.PPThis says \f(CW$a\fR is an \s-1SV\s0, a scalar.  The scalar is an \s-1IV\s0, a number.  Itsreference count is 1.  It has the \f(CW\*(C`IOK\*(C'\fR flag set, meaning it is currentlybeing evaluated as a number.  Because \s-1IOK\s0 is set we look at the \s-1IV\s0 item tosee what is in the scalar..Sh "A simple scalar with an extra reference".IX Subsection "A simple scalar with an extra reference"If the scalar from the previous example had an extra reference:.PP.Vb 4\&        use Devel::Peek;\&        $a = 42;\&        $b = \e$a;\&        Dump $a;.Ve.PPThe output:.PP.Vb 4\&        SV = IV(0xbe860)\&          REFCNT = 2\&          FLAGS = (IOK,pIOK)\&          IV = 42.Ve.PPNotice that this example differs from the previous example only in itsreference count.  Compare this to the next example, where we dump \f(CW$b\fRinstead of \f(CW$a\fR..Sh "A reference to a simple scalar".IX Subsection "A reference to a simple scalar"This shows what a reference looks like when it references a simple scalar..PP.Vb 4\&        use Devel::Peek;\&        $a = 42;\&        $b = \e$a;\&        Dump $b;.Ve.PPThe output:.PP.Vb 8\&        SV = RV(0xf041c)\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0xbab08\&        SV = IV(0xbe860)\&          REFCNT = 2\&          FLAGS = (IOK,pIOK)\&          IV = 42.Ve.PPStarting from the top, this says \f(CW$b\fR is an \s-1SV\s0.  The scalar is an \s-1RV\s0, areference.  It has the \f(CW\*(C`ROK\*(C'\fR flag set, meaning it is a reference.  Because\&\s-1ROK\s0 is set we have an \s-1RV\s0 item rather than an \s-1IV\s0 or \s-1PV\s0.  Notice that Dumpfollows the reference and shows us what \f(CW$b\fR was referencing.  We see thesame \f(CW$a\fR that we found in the previous example..PPNote that the value of \f(CW\*(C`RV\*(C'\fR coincides with the numbers we see when westringify \f(CW$b\fR. The addresses inside \s-1\fIRV\s0()\fR and \s-1\fIIV\s0()\fR are addresses of\&\f(CW\*(C`X***\*(C'\fR structure which holds the current state of an \f(CW\*(C`SV\*(C'\fR. Thisaddress may change during lifetime of an \s-1SV\s0..Sh "A reference to an array".IX Subsection "A reference to an array"This shows what a reference to an array looks like..PP.Vb 3\&        use Devel::Peek;\&        $a = [42];\&        Dump $a;.Ve.PPThe output:.PP.Vb 10\&        SV = RV(0xf041c)\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0xb2850\&        SV = PVAV(0xbd448)\&          REFCNT = 1\&          FLAGS = ()\&          IV = 0\&          NV = 0\&          ARRAY = 0xb2048\&          ALLOC = 0xb2048\&          FILL = 0\&          MAX = 0\&          ARYLEN = 0x0\&          FLAGS = (REAL)\&        Elt No. 0 0xb5658\&        SV = IV(0xbe860)\&          REFCNT = 1\&          FLAGS = (IOK,pIOK)\&          IV = 42.Ve.PPThis says \f(CW$a\fR is an \s-1SV\s0 and that it is an \s-1RV\s0.  That \s-1RV\s0 points toanother \s-1SV\s0 which is a \s-1PVAV\s0, an array.  The array has one element,element zero, which is another \s-1SV\s0. The field \f(CW\*(C`FILL\*(C'\fR above indicatesthe last element in the array, similar to \f(CW\*(C`$#$a\*(C'\fR..PPIf \f(CW$a\fR pointed to an array of two elements then we would see thefollowing..PP.Vb 3\&        use Devel::Peek \*(AqDump\*(Aq;\&        $a = [42,24];\&        Dump $a;.Ve.PPThe output:.PP.Vb 10\&        SV = RV(0xf041c)\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0xb2850\&        SV = PVAV(0xbd448)\&          REFCNT = 1\&          FLAGS = ()\&          IV = 0\&          NV = 0\&          ARRAY = 0xb2048\&          ALLOC = 0xb2048\&          FILL = 0\&          MAX = 0\&          ARYLEN = 0x0\&          FLAGS = (REAL)\&        Elt No. 0  0xb5658\&        SV = IV(0xbe860)\&          REFCNT = 1\&          FLAGS = (IOK,pIOK)\&          IV = 42\&        Elt No. 1  0xb5680\&        SV = IV(0xbe818)\&          REFCNT = 1\&          FLAGS = (IOK,pIOK)\&          IV = 24.Ve.PPNote that \f(CW\*(C`Dump\*(C'\fR will not report \fIall\fR the elements in the array,only several first (depending on how deep it already went into thereport tree)..Sh "A reference to a hash".IX Subsection "A reference to a hash"The following shows the raw form of a reference to a hash..PP.Vb 3\&        use Devel::Peek;\&        $a = {hello=>42};\&        Dump $a;.Ve.PPThe output:.PP.Vb 10\&        SV = RV(0x8177858) at 0x816a618\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0x814fc10\&          SV = PVHV(0x8167768) at 0x814fc10\&            REFCNT = 1\&            FLAGS = (SHAREKEYS)\&            IV = 1\&            NV = 0\&            ARRAY = 0x816c5b8  (0:7, 1:1)\&            hash quality = 100.0%\&            KEYS = 1\&            FILL = 1\&            MAX = 7\&            RITER = \-1\&            EITER = 0x0\&            Elt "hello" HASH = 0xc8fd181b\&            SV = IV(0x816c030) at 0x814fcf4\&              REFCNT = 1\&              FLAGS = (IOK,pIOK)\&              IV = 42.Ve.PPThis shows \f(CW$a\fR is a reference pointing to an \s-1SV\s0.  That \s-1SV\s0 is a \s-1PVHV\s0, ahash. Fields \s-1RITER\s0 and \s-1EITER\s0 are used by \f(CW\*(C`each\*(C'\fR..PPThe \*(L"quality\*(R" of a hash is defined as the total number of comparisons neededto access every element once, relative to the expected number needed for arandom hash. The value can go over 100%..PPThe total number of comparisons is equal to the sum of the squares of thenumber of entries in each bucket.  For a random hash of \f(CW\*(C`<n\*(C'\fR> keys into\&\f(CW\*(C`<k\*(C'\fR> buckets, the expected value is:.PP.Vb 1\&                n + n(n\-1)/2k.Ve.Sh "Dumping a large array or hash".IX Subsection "Dumping a large array or hash"The \f(CW\*(C`Dump()\*(C'\fR function, by default, dumps up to 4 elements from atoplevel array or hash.  This number can be increased by supplying asecond argument to the function..PP.Vb 3\&        use Devel::Peek;\&        $a = [10,11,12,13,14];\&        Dump $a;.Ve.PPNotice that \f(CW\*(C`Dump()\*(C'\fR prints only elements 10 through 13 in the above code.The following code will print all of the elements..PP.Vb 3\&        use Devel::Peek \*(AqDump\*(Aq;\&        $a = [10,11,12,13,14];\&        Dump $a, 5;.Ve.Sh "A reference to an \s-1SV\s0 which holds a C pointer".IX Subsection "A reference to an SV which holds a C pointer"This is what you really need to know as an \s-1XS\s0 programmer, of course.  Whenan \s-1XSUB\s0 returns a pointer to a C structure that pointer is stored in an \s-1SV\s0and a reference to that \s-1SV\s0 is placed on the \s-1XSUB\s0 stack.  So the output froman \s-1XSUB\s0 which uses something like the T_PTROBJ map might look something likethis:.PP.Vb 11\&        SV = RV(0xf381c)\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0xb8ad8\&        SV = PVMG(0xbb3c8)\&          REFCNT = 1\&          FLAGS = (OBJECT,IOK,pIOK)\&          IV = 729160\&          NV = 0\&          PV = 0\&          STASH = 0xc1d10       "CookBookB::Opaque".Ve.PPThis shows that we have an \s-1SV\s0 which is an \s-1RV\s0.  That \s-1RV\s0 points at another\&\s-1SV\s0.  In this case that second \s-1SV\s0 is a \s-1PVMG\s0, a blessed scalar.  Because it isblessed it has the \f(CW\*(C`OBJECT\*(C'\fR flag set.  Note that an \s-1SV\s0 which holds a Cpointer also has the \f(CW\*(C`IOK\*(C'\fR flag set.  The \f(CW\*(C`STASH\*(C'\fR is set to the packagename which this \s-1SV\s0 was blessed into..PPThe output from an \s-1XSUB\s0 which uses something like the T_PTRREF map, whichdoesn't bless the object, might look something like this:.PP.Vb 10\&        SV = RV(0xf381c)\&          REFCNT = 1\&          FLAGS = (ROK)\&          RV = 0xb8ad8\&        SV = PVMG(0xbb3c8)\&          REFCNT = 1\&          FLAGS = (IOK,pIOK)\&          IV = 729160\&          NV = 0\&          PV = 0.Ve.Sh "A reference to a subroutine".IX Subsection "A reference to a subroutine"Looks like this:.PP.Vb 10\&        SV = RV(0x798ec)\&          REFCNT = 1\&          FLAGS = (TEMP,ROK)\&          RV = 0x1d453c\&        SV = PVCV(0x1c768c)\&          REFCNT = 2\&          FLAGS = ()\&          IV = 0\&          NV = 0\&          COMP_STASH = 0x31068  "main"\&          START = 0xb20e0\&          ROOT = 0xbece0\&          XSUB = 0x0\&          XSUBANY = 0\&          GVGV::GV = 0x1d44e8   "MY" :: "top_targets"\&          FILE = "(eval 5)"\&          DEPTH = 0\&          PADLIST = 0x1c9338.Ve.PPThis shows that.IP "\(bu" 4the subroutine is not an \s-1XSUB\s0 (since \f(CW\*(C`START\*(C'\fR and \f(CW\*(C`ROOT\*(C'\fR arenon-zero, and \f(CW\*(C`XSUB\*(C'\fR is zero);.IP "\(bu" 4that it was compiled in the package \f(CW\*(C`main\*(C'\fR;.IP "\(bu" 4under the name \f(CW\*(C`MY::top_targets\*(C'\fR;.IP "\(bu" 4inside a 5th eval in the program;.IP "\(bu" 4it is not currently executed (see \f(CW\*(C`DEPTH\*(C'\fR);.IP "\(bu" 4it has no prototype (\f(CW\*(C`PROTOTYPE\*(C'\fR field is missing)..SH "EXPORTS".IX Header "EXPORTS"\&\f(CW\*(C`Dump\*(C'\fR, \f(CW\*(C`mstat\*(C'\fR, \f(CW\*(C`DeadCode\*(C'\fR, \f(CW\*(C`DumpArray\*(C'\fR, \f(CW\*(C`DumpWithOP\*(C'\fR and\&\f(CW\*(C`DumpProg\*(C'\fR, \f(CW\*(C`fill_mstats\*(C'\fR, \f(CW\*(C`mstats_fillhash\*(C'\fR, \f(CW\*(C`mstats2hash\*(C'\fR bydefault. Additionally available \f(CW\*(C`SvREFCNT\*(C'\fR, \f(CW\*(C`SvREFCNT_inc\*(C'\fR and\&\f(CW\*(C`SvREFCNT_dec\*(C'\fR..SH "BUGS".IX Header "BUGS"Readers have been known to skip important parts of perlguts, causing muchfrustration for all..SH "AUTHOR".IX Header "AUTHOR"Ilya Zakharevich	ilya@math.ohio\-state.edu.PPCopyright (c) 1995\-98 Ilya Zakharevich. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself..PPAuthor of this software makes no claim whatsoever about suitability,reliability, edability, editability or usability of this product, andshould not be kept liable for any damage resulting from the use ofit. If you can use it, you are in luck, if not, I should not be keptresponsible. Keep a handy copy of your backup tape at hand..SH "SEE ALSO".IX Header "SEE ALSO"perlguts, and perlguts, again.

⌨️ 快捷键说明

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