Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Indented properly with tabs.
Indentation width set to 3.
Whitespaces shown.

Code is lined up properly.

Indentation width set changed to 8.
Code remains lined up properly.

...

The editor's indentation with is changed to 8.
The only shifts are reflected in the tabs.

The code remains lined up properly and easy to read.

Comments

Comment as much as sanely possible

...

!

There should always be at least 1 space between the # character and the beginning of the comment.  This makes it a little easier to read multi-line comments:

No

...

Yes

#Comments are your friend, they help
#other developers understand your brilliance.

...

# Comments are your friend, they help
# other developers understand your brilliance.

Subroutine & Variable Names

...

Single letter variable names should never be used unless for a loop iterator:

No

...

Yes

OK

OK

my $m = '00:50:56:12:88:99';

...

my $mac_address = '00:50:56:12:88:99';

...

for (my $loop = 0; $loop<=10; $loop++) {

...

for (my $i = 0; $i<=10; $i++) {

Avoid abbreviations:

No

Yes

No

...

Yes

my $ip_addr;

my $ip_address;

sub get_comp_name {

...

sub get_computer_name {

...

Use underscores to separate words:

No

Yes

No

...

Yes

sub getcomputername {

...

sub get_computer_name {

...

my $endtime;

...

my $end_time;

All subroutine names should be entirely lowercase:

No

...

Yes

sub updateRequestState {

...

sub update_request_state {

All variable names defined in subroutines should entirely lowercase:

No

...

Yes

my $requestState;

...

my $request_state;

All class variables defined at the top of a .pm file should be entirely uppercase:

Yes

...


our $SOURCE_CONFIGURATION_DIRECTORY = "$TOOLS/Windows";

Never mix upper and lowercase:

No

...


Yes

my $ipAddress;

...

my $ip_

...

address;

POD Documentation

All modules and subroutines must contain a POD documentation block describing what it does. POD is "Plain Old Documentation". For more information, see:

...

Curly Brackets, Parenthesis

There should be a space between every control/loop keyword and the opening parenthesis:

No

...

Yes

No

Yes

if($loop_count <= 10) {

...

if ($loop_count <= 10) {

...

while($loop_count <= 10) {

...

while ($loop_count <= 10) {

There should be a space between every closing parenthesis and the opening curly bracket:

No

Yes

No

...


Yes

if ($loop_count <= 10){

...

if ($loop_count <= 10) {

...

while ($loop_count <= 10){

...

while ($loop_count <= 10) {

If/Else Statements

'else' & 'elsif' statements should be on a separate line after the previous closing curly brace:

No

...


Yes

if ($end_time < $now) {
   ...
} else {
   ...

...

}

...

if ($end_time < $now) {
   ...
}
else {
   ...
}