mod_perl logo perl icon
previous page: MPMs - Multi-Processing Model Modulespage up: Developer's guidenext page: Porting Apache:: XS Modules from mod_perl 1.0 to 2.0

mod_perl Coding Style Guide






Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford
Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams
mod_perl2 User's Guide

mod_perl2 User's Guide

By Stas Bekman, Jim Brandt


Table of Contents

Description

This document explains the coding style used in the core mod_perl development and which should be followed by all core developers.



TOP

Coding Style Guide

We try hard to code mod_perl using an identical style. Because everyone in the team should be able to read and understand the code as quickly and easily as possible. Some will have to adjust their habits for the benefit of all.

Here are the rough guidelines with more stress on the Perl coding style.



TOP

Function and Variable Prefixes Convention



TOP

Coding Guidelines

The following are the Perl coding guidelines:



TOP

Global Variables



TOP

Modules



TOP

Methods



TOP

Inheritance



TOP

Symbol tables



TOP

Use of $_ in loops

Avoid using $_ in loops unless it's a short loop and you don't call any subs from within the loop. If the loop started as short and then started to grow make sure to remove the use of $_:

Do:

  for my $idx (1..100) {
      ....more than few lines...
      foo($idx);
      ....
  }

Don't:

   for (1..100) {
       ....more than a few statements...
       foo();
       ....
   }

Because foo() might change $_ if foo()'s author didn't localize $_.

This is OK:

   for (1..100) {
       .... a few statements with no subs called
       # do something with $_
       ....
   }


TOP

Maintainers

Maintainer is the person(s) you should contact with updates, corrections and patches.

Stas Bekman [http://stason.org/]



TOP

Authors

Only the major authors are listed above. For contributors see the Changes file.






TOP
previous page: MPMs - Multi-Processing Model Modulespage up: Developer's guidenext page: Porting Apache:: XS Modules from mod_perl 1.0 to 2.0