Devel::Peek shows you the internal details of scalars.

>perl -e"use Devel::Peek; $x='123'; Dump($x); 0+$x; Dump($x);" SV = PV(0x2369cc) at 0x182a22c REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x23fee4 "123"\0 CUR = 3 LEN = 4 SV = PVIV(0x182005c) at 0x182a22c REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 123 PV = 0x23fee4 "123"\0 CUR = 3 LEN = 4

illguts explains this area.

And then there's -MO=Concise to show you the opcode tree.

>perl -MO=Concise -e"for (1..2) { print qq{Hello World\n} }" g <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v ->3 f <2> leaveloop vK/2 ->g 7 <{> enteriter(next->c last->f redo->8) lKS/8 ->d - <0> ex-pushmark s ->3 - <1> ex-list lK ->6 3 <0> pushmark s ->4 4 <$> const[IV 1] s ->5 5 <$> const[IV 2] s ->6 6 <#> gv[*_] s ->7 - <1> null vK/1 ->f e <|> and(other->8) vK/1 ->f d <0> iter s ->e - <@> lineseq vK ->- 8 <;> nextstate(main 1 -e:1) v ->9 b <@> print vK ->c 9 <0> pushmark s ->a a <$> const[PV "Hello World\n"] s ->b c <0> unstack v ->d -e syntax OK >perl -MO=Concise,-exec -e"for (1..2) { print qq{Hello World\n} }" 1 <0> enter 2 <;> nextstate(main 2 -e:1) v 3 <0> pushmark s 4 <$> const[IV 1] s 5 <$> const[IV 2] s 6 <#> gv[*_] s 7 <{> enteriter(next->c last->f redo->8) lKS/8 d <0> iter s e <|> and(other->8) vK/1 8 <;> nextstate(main 1 -e:1) v 9 <0> pushmark s a <$> const[PV "Hello World\n"] s b <@> print vK c <0> unstack v goto d f <2> leaveloop vK/2 g <@> leave[1 ref] vKP/REFC -e syntax OK

You can locate the code for each op by searching for pp_op_name. It'll be in one of the pp*.c files. For example, the code for enteriter is in pp_enteriter in pp_ctl.c.

This provides a good entry into perl since you're looking at code whose function you already know.


In reply to Re: Understanding the Perl Interpreter by ikegami
in thread Understanding the Perl Interpreter 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.