Hiya Monks,

I'm trying to grok the infamous 'B' Module.
http://search.cpan.org/perldoc?B

This documentation assumes that the reader knows a fair amount about perl's internals including such things as SVs, OPs and the internal symbol table and syntax tree of a program.

I've read through the most obvious places... http://perldoc.perl.org/DB.html
http://perldoc.perl.org/perldebug.html
http://perldoc.perl.org/perldebguts.html
/usr/libdata/perl5/i386-openbsd/5.10.1/CORE/perl.h
/usr/libdata/perl5/i386-openbsd/5.10.1/CORE/handy.h

I'd like to find info on the naming convention and/or name definitions. Basically, what do the names mean and why are they named that way?

NAME    KNOWN           WILD GUESSES
SV      is a scalar     (WTF does the 'V' stand for?)
RV      is a Reference  (well, it was until Perl 5.11.*)
PV      is a string     (WTF does 'P' stand for?)
IV      is an integer
NV      is a number
LV      is ?            ("LeftValue?" LVALUE? Local? )
GV      is ?            (General? Global?, Garbage-Collected?)
AV      is ?            (Array?)
HV      is ?            (Hash?)
CV      is ?
FM      is ?
IO      is ?

PVIV    string and integer slots
PVNV    string and number slots
PVLV    is ?            (string of left value, e.g. func name)

OP                      (Operation?)
COP
LOOP                    (Loop Operation?)
PMOP
PVOP                    (String Operation?)
SVOP                    (Scalar Operation?)
UNOP
BINOP
LOGOP                   (Logic Operation? e.g. 'and' 'or')
PADOP
LISTOP

Much to the surprise of my local prune vendor, 'BM' is Boyer-Moore, a string search algorithm, but as far as I know, it's a no longer a used type/name. Digging around for the obvious is helpful... but it's like trying to learn by osmosis.

$ perl -e 'print(ref(\pos) . "\n");' LVALUE $ perl -e 'use B; print(ref(B::svref_2object(\substr "foo",1)) . "\n") +;' B::PVLV $ perl -MO=Terse -ce '$v=2; $v=2.3; $v="txt"; print index($v,"x",0);' LISTOP (0x7d61afc0) leave [1] OP (0x7df6e560) enter COP (0x8b34b340) nextstate BINOP (0x7d61aa60) sassign SVOP (0x7d61a9c0) const IV (0x85306280) 2 UNOP (0x7d61af20) null [15] SVOP (0x7d61afe0) gvsv GV (0x86712440) *v COP (0x8b34b380) nextstate BINOP (0x7d61afa0) sassign SVOP (0x7cd4e6c0) const NV (0x86712460) 2.3 UNOP (0x7d61af60) null [15] SVOP (0x7d61ae60) gvsv GV (0x86712440) *v COP (0x7f6ffe40) nextstate BINOP (0x7df6edc0) sassign SVOP (0x7df6ee60) const PV (0x86712510) "txt" UNOP (0x7df6ed00) null [15] SVOP (0x7df6eca0) gvsv GV (0x86712440) *v COP (0x7f6fff80) nextstate LISTOP (0x7df6ef60) print OP (0x7df6ef20) pushmark LISTOP (0x7d61ac80) index [1] OP (0x7df6ed60) null [3] UNOP (0x7df6eee0) null [15] SVOP (0x7df6eda0) gvsv GV (0x86712440) *v SVOP (0x7d61ad00) const GV (0x867124b0) "x" SVOP (0x7df6eec0) const IV (0x86712470) 0 -e syntax OK $ perl -MO=Terse -ce '@a = qw(1 two 3);foreach (@a) {print "$_\n";}' LISTOP (0x8b2d0ec0) leave [1] OP (0x81b42e00) enter COP (0x8945b100) nextstate BINOP (0x818e7080) aassign [2] UNOP (0x83c67f60) null [142] OP (0x83c67fe0) pushmark SVOP (0x83c67f80) const PV (0x888cf470) "1" SVOP (0x83c67ca0) const PV (0x888cf510) "two" SVOP (0x83c67fa0) const PV (0x888cf4b0) "3" UNOP (0x83c67ce0) null [142] OP (0x8a367fa0) pushmark UNOP (0x83c67f40) rv2av [1] SVOP (0x7e65a4c0) gv GV (0x888cf440) *a COP (0x88486f80) nextstate BINOP (0x87348f00) leaveloop LOOP (0x88486ec0) enteriter OP (0x87348f80) null [3] UNOP (0x873489a0) null [142] OP (0x87348ee0) pushmark UNOP (0x87348a20) rv2av [3] SVOP (0x87348680) gv GV (0x888cf440) *a SVOP (0x87348fc0) gv GV (0x7f67f170) *_ UNOP (0x87348d80) null LOGOP (0x87348f60) and OP (0x87348fa0) iter LISTOP (0x87348e40) lineseq COP (0x8945b140) nextstate LISTOP (0x87348c20) print OP (0x87348d20) pushmark UNOP (0x87348f40) null [67] OP (0x87348e20) null [3] BINOP (0x83c67c60) concat [4] UNOP (0x83c679c0) null [15] SVOP (0x83c67f00) gvsv GV (0x7f67 +f170) *_ SVOP (0x87348da0) const PV (0x888cf49 +0) "\n" OP (0x87348e80) unstack -e syntax OK

If you know were the names are documented, or know that they are undocumented, please kick the knowledge downstairs to the unwashed. Thanks!


In reply to Where to find info on low level perl internals names? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.