| Previous | Next
Perl ExecutableContents:Command Processing
The perl executable is normally installed in /usr/bin or /usr/local/bin on your machine. Some people often refer to perl as the Perl interpreter, but this isn't strictly correct, as you'll learn shortly. Every Perl program must be passed through the Perl executable to be executed. The first line in many Perl programs is something like: #!/usr/bin/perl For Unix systems, this Often, you'll see command-line options tacked on the end of perl, such as the notorious -w switch, which produces warning messages. But almost all Perl programs on Unix start with some variation of If you get a mysterious "Command not found" error on a Perl program, it's often because the path to the Perl executable is wrong. When you download Perl programs off the Internet, copy them from one machine to another, or copy them out of a tutorial (like this one!). The first thing you should do is make sure that the So what does the Perl executable do? It compiles the program internally into a parse tree and executes it immediately. Because the program is not compiled and executed in separate steps, Perl is commonly known as an interpreted language, but this is not quite true.[5]
So do you call something a Perl "script" or a Perl "program"? Typically, the word "program" is used to describe something that needs to be compiled into assembler or bytecode before executing, as in the C language. The word "script" is used to describe something that runs through an executable on your system, such as the Bourne shell. For Perl, you can use either phrase and only offend those Perl developers who care about semantics more than you do. What does all this mean for you? When you write a Perl program, you can just give it a correct Command ProcessingIn addition to specifying a
Perl parses the input file from the beginning, unless you've specified the -x switch (see "Command-Line Options" later in this chapter). If there is a After locating your script, Perl compiles the entire script into an internal form. If there are any compilation errors, execution of the script is not attempted. If the script is syntactically correct, it is executed. If the script runs off the end without hitting an |