This chapter demonstrates about the Perl Coding Standards Each and every program have its own sense of writing the code using certain standards and following are the concepts covered in this chapter.
Coding Standards
Coding Standards
Description
In Perl Programming each and every program will have his own sense of writing the code by using some standards which are familiar with the other programmer and everyone should understand and support the code properly. Every time writing a simple code is easy but when the problems arise it need to maintain at later stages. The programmer needs to follow the proper guidelines and coding standards which need to be followed while writing the code. The programmer needs to load 'strict' and 'warning module' while writing the code which has its own preferences.
Strict
Which is used to declare the variable before using and which is also will tell if any bare word present in the code.
Warning Module
These are alternatively used by passing '-w' option to the Perl interpreter in shebang. a warning will print on the output.
The image below demonstrates the Coding standards as shown.
Some Coding Standards are listed below.
Use 'strict' and 'warnings' modules.
Variable names should be understandable by the others.
Remove variables which are not in use.
While coding a script Documentation is required.
Do not hardcode any values instead of this try to fix the values dynamically or ask a user to enter during run time.
The user needs to give meaning full names for the subroutine.
Try to maintain reusable codes.
Always initialize variables.
Subroutines always return values.
Open curly braces in the same line.
The single-line block may be placed in the same line with curly.
Try to use simple regex while coding.
While writing phrases of words which are written as variable name maintain some underscores.
Summary
Key Points
Every program must have the program standards.
Maintain Variable names as understandable lagugae.