Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Coding standard for programming in PERL.

1. Class name: start with capital letter like CheckMaskprep or CheckVerilog.


2. Class file name: must be same as class name with .pm extension.
3. Always use strict and warning pragma.
4. Group includes files(classes or packages) in three category.
a. global modules
b. application modules
c. local modules
5. Header Info of source file:
# Written By:
# Name :
# Purpose :
# Date :

6. Avoid global variables, but if they are essential then put them in Global.pm(to help reduce
redundancy) file.
7. Function Name: function name should start from lower case like getAssociatedFab().
8. Functionality should explain along with function definition.
9. Variable name should also in camel case format, like $isBinaryCode.
10. Write proper unit test with every function.
11. In case of exception, use “confess” instead of “die”.
12. Use tab before conditional or loop expression.

Sub getAssociatedFab(){

My $self =shift;
If(){
If(){

}
}elsif(){

}else{

13. Always return reference of array or hash from sub routine.


14. Use single quotes where interpolation is not required, as they are more efficient.
15. Constructor should have few lines required for object creation.
Sub new{
My $class = ref(shift @_) | shift @_;
My $self ={};
Bless($class,$shift);
Return $self;
}
16. For object creation of class, use following statement.
17. My $obj = new Check();
18. initialize() function encapsulate all initialization code of script and called from constructor.
19. Instead of if-else use ternary operator(?:).
20. Class function can be divide in two category.
a. Public interface:
Can be use for direct invocation by class object or inherited by derive class.
executeChecks()
detailedReport()
b. Private functions

Only called by public interfaces.

Initialize().

You might also like