Todd Chester has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks

I am new to Perl. Can someone point me to a working paper as to the steps Perl 5 goes through from written text (code) to what actually executes on your processor?

Also, what is the code that actually executes on your processor called? Would this be "machine code" by chance?

Many thanks,

-T

Replies are listed 'Best First'.
Re: How does Perl get to executable code?
by Corion (Patriarch) on Nov 10, 2015 at 10:33 UTC

    I would say that most of this should be covered in your course material.

    The short overview is that Perl creates bytecode, by running the C code that sits behind eval. The resulting bytecode/data structure is then executed by the Perl interpreter. All machine code that Perl runs has already been compiled in the perl executable when the program was built.

Re: How does Perl get to executable code?
by Preceptor (Deacon) on Nov 10, 2015 at 10:27 UTC

    If you are new to perl, this is a sort of question that'll give you a load of answers that don't make a lot of sense. However, I might offer perlguts illustrated for what's going on behind the scenes. Also possibly the perlcompile documentation page

    It does end up as machine code - as does everything that ever runs on your system. But very few people work in machine code any more, because it's low level and hard work and gives very little net benefit outside of some very specific niche applications.

    Practically speaking though - it is unlikely that you will need to be digging this deep with perl - the whole point of it is that it's sufficiently high level that you don't need to care about (most) implementation specific details.

      It does end up as machine code

      Um, no it doesn't. It ends up as bytecode which is then interpreted.

      However, understanding the process somewhat is helpful in diagnosing some script failure modes and in understanding the role that BEGIN and friends play. A related area is understanding how modules are loaded, which also has traps for heffalumps near the edges of the envelope.

      Premature optimization is the root of all job security
Re: How does Perl get to executable code?
by karlgoethebier (Abbot) on Nov 10, 2015 at 11:26 UTC
Re: How does Perl get to executable code?
by Anonymous Monk on Nov 10, 2015 at 12:03 UTC

    The Camel has a good description (Chapter 16, "Compiling").

      Thank you all! I have some reading to do!