Basic Syntax



next up previous
Next: Data Types Up: Previous: What is Perl?

Basic Syntax

Perl is a free-form language like C. Perl's control flow structures are very much like C's. There are no FORTRAN-like line constraints.

Perl programs, by convention, sometimes end in .pl. This is not a requirement, however, and most Perl scripts simply invoke the interpreter through the use of the #! construct. The first line of a Perl script (at least in the UNIX world) usually looks like this:

#!/usr/local/bin/perl

In Perl, every statement must end with a semicolon (;). Text starting with a pound sign (#) is treated as a comment and is ignored.

Blocks of Perl code, such as those following conditional statements or in loops are always enclosed in curly brackets ({...}).