You are viewing the version of this documentation from Perl 5.34.3. View the latest version

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.

Regarding aesthetics of code lay out, 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: