Chapter 3. Syntax

Perl is a free-format programming language. This means that in general it does not matter how a Perl program is written with regard to indentation and lines.

An exception to this rule is when the Perl compiler encounters a sharp or pound symbol (#) in the input: it then discards this symbol and everything following it up to the end of the current input line. This can be used to put comments in Perl programs. Real programmers put lots of useful comments in their programs.

There are places where whitespace does matter: within literal text, patterns, and formats.

If the Perl compiler encounters the special token __END__, it discards this symbol and stops reading input. Anything following this token is ignored by the Perl compiler, but can be read by the program when it is run, using the filehandle DATA.

When Perl is expecting a new statement and encounters a line that starts with =, it skips all input up to and including a line that starts with =cut. This is used to embed documentation.

perlsyn.

Get Perl Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.