Is Perl a compiled or an interpreted programming language?

前端 未结 9 2052
谎友^
谎友^ 2020-12-24 03:36

Is Perl compiled or interpreted?

9条回答
  •  难免孤独
    2020-12-24 04:01

    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.

提交回复
热议问题