>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.
|