in reply to A Matter of Style in CGI
In keeping with the title, this is very much a matter of style. The one while loop in that code indicates that you seem to like blocks that look like:
while () { ...; }
Blocks structured like that are difficult to read. The eye has to search for the ending curly. Perl isn't Python. In Perl, the curlies define the blocks and you should make them easy to spot. Some people insist that blocks should look like:
while () { ...; }
I prefer blocks that look like:
but I'm guessing that neither of those will appeal to you as much aswhile () { ...; }
or maybewhile () { ...; }
or evenwhile () { ...; }
while () { ...; }
Another reason not to use your current style is that by putting the curly on a separate line, you can add a line to the end of your block without moving the curly. The real benefit of that will be noticeable when you want to move lines of code around. You couldn't just cut that whole line and paste it elsewhere, for instance. That style can really ruin the day for someone that uses vi.
Consistency is probably more important than the actual style you choose but you should still pick one that makes coding easier and your code eaier to read.
-sauoq "My two cents aren't worth a dime.";
|
|---|