O'Reilly logo

Computer Science & Perl Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 68. Basic Perl Anatomy

Chip Salzenberg

In Components of the Perl Distribution, I described the overall content and layout of the perl distribution. Now that the stage has been set, I’ll show how perl implements the Perl language, with occasional excursions into the standard library.

We’ll survey the major portions of perl and their functions. You’ll notice that the word “perl” isn’t always capitalized in this column. That’s because Larry Wall draws a distinction between “Perl” the language and perl the program—in theory, there could be other programs besides perl that implement Perl. Thus, this article is not about “the guts of Perl” but rather “the guts of perl.”

How Perl Works

Here’s a bird’s-eye view of how perl executes your Perl programs:

Lexical analysis

perl reads your program and breaks it down into basic syntactic elements, called tokens.

Parsing

perl figures out the meaning of those tokens in that specific sequence.

Compilation

perl builds an internal structure representing operations that, when executed, will perform the actions specified by your program.

Execution

perl steps through those operations and performs them, one by one.

Note that perl distinguishes Step 3from Step 4. The line is blurred by BEGIN {} blocks, which specify Perl code to be executed during the compilation phase-— before your program runs.

Step 3 settles one of the frequently asked questions about Perl: perl is a compiler, not an interpreter. Specifically, it’s a “load-and-go compiler.” Incidentally, current ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required