You are viewing the version of this documentation from Perl 5.39.6. This is a development version of Perl.

CONTENTS

NAME

perlstyle - Perl style guide

DESCRIPTION

Each programmer will, of course, have his or her own preferences in regards to formatting, but there are some general guidelines that will make your programs easier to read, understand, and maintain.

The most important thing is to use strict and warnings in all your code or know the reason why not to. You may turn them off explicitly for particular portions of code via no warnings or no strict, and this can be limited to the specific warnings or strict features you wish to disable. The -w flag and $^W variable should not be used for this purpose since they can affect code you use but did not write, such as modules from core or CPAN.

A concise way to arrange for this is to use the use VERSION syntax, requesting a version 5.36 or above, which will enable both the strict and warnings pragmata (as well as several other useful named features).

use v5.36;

Regarding aesthetics of code layout, about the only thing Larry cares strongly about is that the closing curly bracket of a multi-line BLOCK should line up with the keyword that started the construct. Beyond that, he has other preferences that aren't so strong:

Larry has his reasons for each of these things, but he doesn't claim that everyone else's mind works the same as his does.

Here are some other more substantive style issues to think about: