UBB.Dev
Posted By: Mark Badolato Perl Style Guide - 03/06/2001 6:11 AM
I've been looking at a lot of code lately, and it pains me to see how unstructured and randomly formatted it is.

A nice, clear, consistant layout of the code goes a LONG way to debugging code, or understanding it.

With that in mind, I would suggest a reading of the Perl Style Guide as it contains the recommended style for Perl code.

Upon reading it, the first question people always ask me is "what's an uncuddled else?"

this is cuddled:

Code
code:

This is the preferred way:

Code
code:

(with the else on its own line)

Everyone has there own style of how they do things. That's fine. If you don't want to go with all of the recommend Perl styles that is ok. BUT, whatever style you choose, please be consistant throughout your code. Don't follow other people's example's and make a mishmash of sloppy looking code.

Code that looks professional gains much higher respect then code that doesn't.

--mark
Posted By: JohnM Re: Perl Style Guide - 03/07/2001 7:16 AM
I personally like the

if (something) {
dosomething;
} else {
somethingelse;
}

better
Posted By: Steven B. Re: Perl Style Guide - 03/08/2001 12:53 AM
I agree with Mark that a script should have consistency, but I prefer:

Code
code:

Though the other looks good too; but John, that snippet of yours looks fine there but in a script the size of UBB (or even half the size) it makes it a pain.
Posted By: Mark Badolato Re: Perl Style Guide - 03/08/2001 3:49 AM
The reason I don't prefer the cuddled elses is because it makes more sense to have them exactly lined up under their corresponding if statement. Plus the makes the blocks more segmented.

Personal preference, I prefer the way the style guide mentions.
Posted By: JohnM Re: Perl Style Guide - 03/08/2001 5:11 AM
Quote
quote:
Um, yours is the same as mine....
Posted By: Steven B. Re: Perl Style Guide - 03/08/2001 4:04 PM
Quote
quote:
You have no indentation on yours. That's what I was referring to.
Posted By: Greg Hard Re: Perl Style Guide - 03/12/2001 2:23 AM
I personally prefer:

Code
code:

One liners, ya know? If i must use else, which for most of my code i dont, i prefer:

Code
code:

[ March 11, 2001: Message edited by: MasterMind ]
© UBB.Developers