Skip to content

Commit b7a1142

Browse files
author
aishwarya-sankhla
committed
Add code tags
1 parent 01d5b52 commit b7a1142

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

guides/coding_style/perl/style.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Perl Code Style Guidelines
22

3+
```perl
34
Indentation:
45
Tabs should be used to indent all code blocks. Spaces should never be used to indent code blocks. Mixing tabs and spaces results in misaligned code blocks for other developers who prefer different indentation settings.
5-
66
if ($total_hours >= 24) {
77
return 1;
88
}
@@ -14,27 +14,41 @@ else {
1414
return 0;
1515
}
1616
}
17+
```
1718

19+
```perl
1820
Comments:
1921
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:
2022
# Comments are your friend, they help
23+
```
2124

25+
```perl
2226
Subroutine & Variable Names:
2327
Single letter variable names should never be used unless for a loop iterator:
28+
```
2429

30+
```perl
2531
Avoid abbreviations:
2632
my $ip_addr; ->No
2733
my $ip_address; ->Yes
34+
```
2835

36+
```perl
2937
Use underscores to separate words:
3038
sub get_computer_name {
39+
```
3140

41+
```perl
3242
All subroutine names should be entirely lowercase:
3343
sub update_request_state {
44+
```
3445

46+
```perl
3547
All class variables defined at the top of a .pm file should be entirely uppercase:
3648
our $SOURCE_CONFIGURATION_DIRECTORY = "$TOOLS/Windows";
49+
```
3750

51+
```perl
3852
POD Documentation
3953
All modules and subroutines must contain a POD documentation block describing what it does. POD is "Plain Old Documentation".
4054

@@ -54,11 +68,15 @@ Each subroutine should begin with a POD block with the following format:
5468
sub my_subroutine_name {
5569

5670
}
71+
```
5772

73+
```perl
5874
Curly Brackets, Parenthesis:
5975
There should be a space between every control/loop keyword and the opening parenthesis:
6076
if ($loop_count <= 10) {
77+
```
6178

79+
```perl
6280
If/Else Statements:
6381
'else' & 'elsif' statements should be on a separate line after the previous closing curly brace:
6482
if ($end_time < $now) {
@@ -67,3 +85,4 @@ if ($end_time < $now) {
6785
else {
6886
...
6987
}
88+
```

0 commit comments

Comments
 (0)