Perl Adapter Project

Coding Guide

Version: 1.0

These coding standards are meant to be a guide, something to shoot for, in our code.

As all of us programmers know, we like to use our own style, and our favorite editor. So what we would suggest is if you are extremely resistant to changing the way you like to type your code, you may want to get an editor like SlickEdit which can emulate vi or emacs and some other popular editors. Then set SlickEdit up to "beautify" your source after you've written your code so that it conforms to the standard.

The other thing that we would like to do is use pod2html. There is an example in the file header. Be careful to use it exactly as is because any additions or deletions of whitespace/newlines will confuse the pod2html program.

File names

All Perl files should end in the extension ".pl". All Perl functions grouped together into a package file should have the extension ".pm". The first line of a Perl file should have the location of Perl, we will use "#!/usr/local/bin/perl" since this is the most common location of Perl when it is installed.

File and Subroutine Headers

Here is an example file header:


# ------------------------------------------------------------------------ #
# Copyright (c) 2000 Open3.org
# All Rights Reserved.
# 
# This software is licensed under the Open3.org Public License (OPL)
# By using, modifying or distributing this software in source code or binary
# format, you agree with the terms of the Open3.org Public License (OPL).
# 
# For more information, see:
# 
#      https://open3.org/licenses/OPL.html
# 
# OPEN3.ORG MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
# SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE, OR NON-INFRINGEMENT. OPEN3.ORG SHALL
# NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
# MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
# 
# CopyrightVersion 1.00

=pod

=begin html
 

File name:

    discount.pl

File Description:

    This file is called from the output HTML of discount.cgi when the intranet user wants to edit a discount. This file is also called when the user saves the edited form.

Modifications:

  • 08.10.2000 - DLS - Original code completed.
  • 09.10.2000 - SAF - Put in lots of comments.

Author:

    Sarah A. Farrell

Version:

    Revision: 1.2 Date: 09.10.2000

See also:

=end html =cut # ------------------------------------------------------------------------ # use strict; use CGI; .....

Here is an example of a subroutine header that you want to have converted into a Perl HTML document later on:

   
# ------------------------------------------------------------------------ #
=pod

=begin html
sub parse_data()
    description:

      This procedure is the meat of the whole program. Determines how the CGI was called, then displays the form for an edit or form for a new entry, or if we're doing an update (calls update()).

    params:

      none
=end html =cut # ------------------------------------------------------------------------ # sub parse_data { my ($parent_data, $disc_code_id, $itemhash, $children_count, $listing_text); ..... } ....
When pod2html is run on the file, the output should look similar to this.

Naming Conventions:

Style Conventions:

Last modified: 08.29.2001