Alex Rivera | Logout

Is Perl a compiled or an interpreted programming language?

Asked 2011-03-21T10:46:50.580
28

Is Perl compiled or interpreted?

Edit
Report

3 Answers

60

You aren’t going to get a definite answer, because you haven’t provided a definite question.

Perl is always in one of two states: it is either compiling, or it is executing. That’s why you see talk of “at compile-time” vs “at run-time”. Normally, you get one compile phrase followed by one execution phase, but it need not be that way.

These two phases can also trade back and forth. An eval STRING is a way for the interpreter to call the compiler (so too therefore are do FILE and require). A BEGIN block is a way for the compiler to call the interpreter (so too therefore are use and no).

When you run perl -c, you omit the run-time phase. There are various ways to skip the compile-time phase, but none of them is particularly convenient, or commonplace. Apache’s mod_perl only compiles scripts once but executes them many times. If you use the Byteloader, you can do the same. Et cetera.

The correct answer to whether Perl is compiled or interpreted is simply YES.

answered 2011-03-21T12:12:25.873
-1

Both. First, Perl 6 script is compiled to bytecode (and optimized). Then it is executed (however, you still need Perl interpreter for this). Bytecode is kind of executable code, which is independent from environment it runs on (the same bytecode can run on Unix enviroment on ARM processor, Windows system with x86 and Haiku on x64).

Perl 6 can be compiled to Parrot VM (Virtual Machine) bytecode. Parrot VM is used by Python and Ruby as well.

This is what makes Perl, Ruby and Python faster than PHP, which is just interpreted (can be compiled as well, but you need 3rd party components for this).

answered 2011-03-21T10:55:27.183
-2

Most often interpreted but may be compiled also. about perl compiler

answered 2011-03-21T10:50:59.693

Your Answer