I think it's no great use making guidelines in general. You'll have to agree on guidelines in one project and it's good to have concrete ideas. The actual decisions will depend on the group.
Some of the things you mention are in my eyes means of sane programming (system calls, exit code). I don't think you can work seriously with someone who has to be told these things. Also, I'd never say "SHOULD". Say "MUST", so first of all there is no doubt: "Use strict! No exceptions. That's it." Someone who _really_ knows when to disable strictness, will do it. Someone who doesn't will struggle for a solution and ask for help and then someone else may tell him "This is the exception, you may disable strict here."
So there are some general rules i'd make (and in general i agree with you):
- use strict! Always.
- use warnings! Always.
- Doing CGI? use CGI.pm! Always.
- Parsing commandline options? use Getopt::Long and Configure() it POSIXLY_CORRECT! Always.
- check system calls! Always.
- Use comments to comment, use POD to document. Don't mix these two.
- Avoid Globals!
- Globals are all variables with a scope that is larger (in the sourcecode) than an average screen.
- Name Globals wisely. Follow perlstyle rules
- Use spaces to make things clearer
These are the rules I consider "general". Other things are matter of personal taste but should be equal inside a project:
- open the curly on same line as keyword. Indent next line.
- closing curly on single line, indented as deep as keyword of opening curly.
- curly-rule exceptions are special short blocks (map,grep,sort)
- No space between function name and opening parens.
- No space between array identifier and opening square bracket.
- No space between hash identifier and opeing curly
Now finally the Tab-issue: I really think that one should use tabs, but only for indentation. Don't use tabs for alignement.
if( $a > $b ){
T---return
T---T---cond1 ? val1 :
T---T---cond2 ? val2 :
T---T--- default
T---;
}
This way your alignement won't break in someone else's editor using a different tab-width, but logical indentation is still present. I am really convinced that this is a solution.
--
http:// fruiture.de
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|