O'Reilly logo

Perl Pocket Reference, 5th Edition by Johan Vromans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 is when Perl 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 __DATA__, it discards this symbol and stops reading input. Anything following this token is ignored by the compiler, but can be read by the program when it is run, using the package filehandle DATA.

__END__ behaves like __DATA__ in the top level script (but not in files loaded with require or do) and leaves the remaining contents of the file accessible via the global 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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required