The source file of a program written in Perl is a simple text file with the .pl extension.
This source file must be a non-formatted text file, that is to say a text file in its simplest form, without any special formatting (bold, underline..etc) or special characters, only basic ASCII ones. When the program is ready to be "tested", it can be directly be executed by the interpreter.
Perl is case sensitive, meaning by that a name containing uppercase is considered as being different from the same name written in lowercase. Thus, the specifications of the Perl language indicates that function for the standard output stream must be called print() and Print() or PRINT().
On the other hand, every statement ends with a semicolon.
When a program is long and complicated it may be interesting (recommended) to add comment in the program, that is to say, lines of text that aim to explain how the programs work. These lines will not be taken into account by the interpreter.
The # character allows you to define your comments. Example:
#This is a comment!
Example of a Perl script
Here is the simplest example of a Perl script, the traditional Hello World:
The first line specifies the location of the Perl interpreter on the system. In the example above it is a Unix system, under Windows, the script may look like that:
The second line sends the "Hello World" string to the standard output stream
To write a CGI script, a script whose standard output is to be sent to a web browser, an additional line is needed: