in reply to How does Perl do it it's thing?

Perl does parse and "compile". The perl "interpreter" is really a "parse"->"compile"->"execute" program. "Interpreter" usually implies a read->execute->read loop on your script code.

Perl compiles to a execution tree then starts running the execution tree. Typical systems compile to a linear list of assembly instructions. An execution tree is different than a linear list of assembly instructions in that the branching and expression trees are preserved rather than flattened out as is the case with assembly.

I've heard that there are optimization advantages to preserving the tree structure information. But really I don't know much about perl internals.

Hope that helps.

Replies are listed 'Best First'.
Re: Re: How does Perl do it it's thing?
by tomazos (Deacon) on Aug 07, 2001 at 05:57 UTC
    I've learned many programming languages before, during and after studying computer science at university (Basic, Pascal, C, C++, Java, Gopher, HyperTalk blah blah blah).

    Perl is confusing at first because it doesn't fit into any of the boxes that traditional languages fit into, and my preconceptions of what Perl was going to be like (an advanced scripting language like awk or sed) were completely wrong.

    The best thing to do to truly understand how Perl works is to read Programming Perl, 3rd Edition (O'Reilly) from cover to cover. This book is also known as the "Camel", because it has a picture of a camel on the cover.

    The secret name of Perl is the pathelogically eclectic rubbish lister. The more you learn about Perl the more humorous this name becomes.

    Basically Perl uses the fact that these days we have CPU time and memory to burn. It takes all the advantages of both a compiled language and an interpreted language by half-compiling the raw Perl program into a half-baked execution tree, and then immediately after that it interprets that execution tree to make the final program.

    It is this half-compile, half-interpret process that you are finding confusing - but I think it is important to understand this process in all its detail, so that you can get a deeper understanding of how the perl error reporting systems and debuggers works.