|more useful options|
20 most important Perl Best Practicesby greengaroo (Hermit)
|on Aug 22, 2012 at 18:27 UTC||Need Help??|
Let's meditate for a while...
Latest Update: Monks, I created a follow-up thread to this one: 20 tips to avoid pitfalls while Programming Perl
Update: Monks, thank you very much for your responses. Every one of you contributed valuable thoughts. Even if I didn't reply to your post, I have read it and I'm considering what you said. I have decided to rethink my strategy and I will let you know when I am ready with something new. You may still contribute if you like, I will keep following this thread. Thanks again!
Untouched original post here:
For my work, I am trying to compile a list of the 20 most important Perl Best Practices. I don't want to have too many, because I don't want to scare people, but I want to have enough to improve the quality of the code developed by less experienced co-workers (or some careless ones). So far, I came up with 13, so I am missing 7 to complete my list. If you wish to contribute to the list, I would really appreciate it! Plus, I hope it could benefit people who read this thread.
I have read Perl Best Practices from Damian Conway (O'Reilly), I think it is a great book but I really want to limit myself to 20 best practices. Certainly, there are practices more important than others. In my opinion, there is three goals to following a set of best practices while developing Perl code:
Here is my list:
1) Place a semicolon after every statement.
2) Never place two statements on the same line.
3) Always start your elsif or else block on a new line.
4) Always use a label on loops when using next, last and redo.
5) Use lowercase characters and underscore to separate words in an identifier.
6) Use CamelCase or uppercase for package names.
7) Use uppercase characters and underscore to separate words in a constant.
8) In classes, prefix subroutines with an underscore to identify an "internal use only" method.
9) Never use $_ or the invisible equivalent.
10) Never use @_ in subroutines.
11) Always use if blocks, never postfix if statements as a one-liner.
12) Use postfix if statements when using flow of control commands.
13) Use unless and until as little as possible.
Monks, what do you think? This thread is opened to debate, if you don't like what I have put in the list, please let me know, and most importantly, explain why.
Take my advice. I don't use it anyway.