Perl compiles the source code into a graph called the Opcode tree. At the same time, this data structure is the syntax and control flow of your program. To understand the operation codes, you can start with Illustrated Perl Guts .
To find out what your program was compiled with, you call it like this:
perl -MO=Concise script.pl - to get operation codes in their syntax treeperl -MO=Concise,-exec script.pl - -exec . .perl -MO=Concise,foo script.pl - foo.
:
4 <$> const[PV "007B"] s/FOLD ->5
^ ^ ^ ^ ^
| | | | The next op in execution order
| | | Flags for this op, documented e.g. in illguts. "s" is
| | | scalar context. After the slash, op-specific stuff
| | The actual name of the op, may list further arguments
| The optype ($: unop, 2: binop, @:listop) β not really useful
The op number
PP(pp_const). , ack, grep Perl. C :
$ ack 'pp_const' *.c *.h
( ):
op.c
29: * points to the pp_const() function and to an SV containing the constant
30: * value. When pp_const() is executed, its job is to push that SV onto the
pp_hot.c
40:PP(pp_const)
opcode.h
944: Perl_pp_const,
pp_proto.h
43:PERL_CALLCONV OP *Perl_pp_const(pTHX);
, pp_hot.c, 40. vim pp_hot.c +40, . :
PP(pp_const)
{
dVAR;
dSP;
XPUSHs(cSVOP_sv);
RETURN;
}
, Perl API , , XS.
source
share