From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Be consistent

Be consistent - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Be consistent

- [Voiceover] There are a few things you can do which will greatly enhance the reliability and readability of your code. Consistency is more important in Perl than in other languages because Perl can be so forgiving of undisciplined coding practices. Perl's motto, "There's more than one way to do it" can be a blessing and a curse. I strongly suggest that you find one way to do it, whatever, "it" is and stick to that as much as possible. If it seems like a good idea to change it in a particular instance, take the time to analyze that instance. Understand why it may work better another way and make yourself a fitting and repeatable rule for it. The semicolon at the end of a block is optional in Perl even with strict and warnings enabled. If you choose to omit the semicolon and you later rearrange the code or add lines at the end, it can be easy for that line to end up elsewhere and the missing semicolon to become a problem. It's best to just get into the habit and always include it…

Contents