tags:

views:

142

answers:

2

After going through couple of linksI came to know that Perl does the compilation and create an intermediate byte code and then interpret that byte code. My question is where does that byte code reside?

Like in other language like java, c we can see the machine executable object code after compilation. Though Perl doesn't create machine executable code, but there should be some location where it stores the byte code temporarily.

+3  A: 

It stores it in memory as an AST.

Chas. Owens
While there is exciting work, mostly driven by Gerard Goosen, going on to actually give perl an abstract syntax tree, it currently doesn't have one.
rafl
Besides, why would you need an AST for byte code? An AST, since it's about _Syntax_ , only is relevant for languages that have real syntax, e.g. Perl source code.
MSalters
This is only true for Perl 6. Not for Perl 5. Also the AST is not what *stores* the bytecode. It is what can be used to *generate* the bytecode.
dolmen
+16  A: 

The result of the compilation is stored in memory as a tree of opcodes, or optree for short. This structure is being walked by perl's runtime to execute your program.

You will probably find the "Compiled Code" section of perlguts interesting. It explains many of the details of building an executing a perl optree.

It's also sort of possible to write that optree out to disk and load it again into another perl process, using the B::C distribution and the ByteLoader module contained in it. However, this technique doesn't work all that well on many programs, so it's not recommended in any way.

rafl