Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
User Journal

Journal brlancer's Journal: Some of my Perl coding style (transferable to anything)

  • Always use "use strict;". Include "use warnings;" during development and when there will be no "users".
  • Use proper scope
    Declare all variables with "my" or "local"; "my" is preferred because it is more commonly used and understood.
  • Blocks are indented by two spaces
    All blocks are indented two spaces (not \t but spaces).
  • Blocks include their brace before the indentation and after
    If braces are used, they are placed on the line that begins the block and on a separate line after the block.
  • Comments that end before the 70th character are on a single line without leading comment lines. Comment lines that end after the 70th characters have a preceding and following comment line.
  • Arrays are instantiated with elements on individual lines, indented to match the first character of the first element with the opening parenthesis on the same line as the first element and the closing parenthesis on the same line as the last element.

I've noticed several design suggestions in your code.

Working...