A.1 Command Interpretation

The Perl programs in this book start with a line something like:


On Unix (or Linux) systems, the first line of a file can include the name of a program and some flags, which are optional. The line must start with #!, followed by the full pathname of the program (in this case, the Perl interpreter), followed optionally by a single group of one or more flags. It's common in Perl programs to see the -w flag on this first command interpreter line, like so:

 #!/usr/bin/perl -w

The -w flag turns on extra warnings. I prefer to do that with the line:

use warnings;

because it's more portable to different operating systems.

If the Perl program file is called myprogram and has executable permissions, you can type myprogram (or possibly ./myprogram or the full or relative pathname for the program) to start the program running.

The Unix operating system starts the program specified in the command interpretation line and gives it as input the rest of the file after the first line. So, in this case, it starts the Perl interpreter and gives it the program in the file to run.

This is just a shortcut for typing the following at the command line:

/usr/bin/perl myprogram