CIW Course Revision Site


Perl - Writing Bug-Free Perl Code

In a Nutshell - CIW Course Section 2, Part B3, Chapter 9

 

Keep your code bug-freeBest Practice

There is no such thing as bug-free code, at least not at first-pass. Adhering to strict conventions and following best practices can help minimise the risk of technology termites, and thorough testing will help eradicate persistent pests.

Even the best, most experienced programmers will encounter bugs. It goes with the territory. This does not apply solely to Perl, any programming language is prone to the same dangers.

The following guidelines are given in the course, primarily, for ease of reading, but, which in turn will make errors less likely.

Guidelines for Using Spaces
 

Put space before the opening brace of a multiline BLOCK

Put a short BLOCK, including braces, on one line

Omit the semicolon in a short one-line block

Surround most operators with space

Break long lines after and operator, but before and, and or

Put blank lines between chunks of code that do different things

Put a new line between a clsing brace and else

Do not put space between a function name and its opening parenthesis

Put space after each comma

Surround complex subscript with space

No Bugs Please
Keep this place a bug-free zone

Design by Stephen

Certified Internet Webmaster

Page last Edited: 10 Nov 2011