metamod:perl_code_style

This is an old revision of the document!


Coding guidelines

These rules apply to perl and php, unless otherwise mentioned.

  • spaces instead of tabs
  • indent is 4 spaces
  • cuddled else:
    if ($a > $b) {
        $a++;
    } else {
        $b++;
    }
  • Line-length: usually <80 characters, not more than 120 chars
  • translate parameter from @_ to names in start of sub
  • POD(perl)/Doxygen(php) API documentation for modules, close to code
  • POD(perl) documentation for scripts (pod2usage)
  • variables: lower case, underscore splits words
  • constants: upper case, underscore splits words
  • functions: lower case, underscore splits words
  • modules/classes: upper case first, camel case splits words

The following Perltidy configuration can be used as a guideline for formatting the code in Metamod. Don't use perl-tidy blindly on code in particular on others code! Use perltidy for diff.

# make some defaults explicit to document the decision
--indent-columns=4
--cuddled-else
--indent-block-comments
--paren-tightness=1
--square-bracket-tightness=1
--brace-tightness=1
--block-brace-tightness=0
-nbl
-nsbl
--static-block-comments

# deviations from the default
--maximum-line-length=120
--continuation-indentation=4
--opening-brace-always-on-right
--closing-token-indentation=0

FIXME

FIXME

FIXME

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • metamod/perl_code_style.1278928935.txt.gz
  • Last modified: 2022-05-31 09:23:19
  • (external edit)