OI!

We speak about style a lot. Do we put subs near the top, or do we insist on having them at the bottom? Do we cuddle our elses? How are our variables named, do we have space after commas, where's the opening curly anyway? Do we like arrows or double sigils? And what about indenting?

We all have different opinions about style. Style is very personal, so that may or may not be a good thing. However, we argue about style a lot, and never really sum our favourite style.

The Perl Style Geekcode was inspired by the original Geekcode and the Perl Geekcode, but because I didn't want to imply good or bad, I chose to use digits instead of + and -.
I leave a lot of subjects untouched, like programming logic, infinite loops, module usage, and a lot more. Sorry 'bout that.

Here it is:

Updates are denoted by a coloured character in front of what has been added or changed.
% 2002-03-25 16:32 CET
% 2002-03-25 18:13 CET

I - Indenting

Add the number of spaces you use, or t if you use only tabs. % If you use tabs, you can add "=4" to indicate you have set your editor to show tabs as 4 spaces.
Those who consider a tab to be multiple normal indents, may also suffix t, but with a number.
% If you have your editor change existing code automatically to follow your style, add an exclamation mark.

Example: 4-space indents and tab is two of those: I4t2
% Example: tab indents, but shown as 4 characters: It=4
% Example: I make my editor convert tabs to 8 spaces: I8t!
% Example: I use tabs, but I consider 8 spaces equal to one tab: It=8

O - opening curly

Example: on the same line and space before: Os1

; - semicolon

S - whitespace around operators

Add signs to the following items. The possible signs are (with X as the item): Add a question mark on the _inside_ if you change style a lot: x?>

The operators: qw(, . + ** = && and ++ gt ==) Plus implies all simple math operators, what you say for && goes for ||, gt is all comparison operators, and so forward. With ++, it's only about between ++ and its variable.
%With ++ it's only about the difference between $foo++ and $foo ++ (choose any direction).

Example: S,><.><+>**<=><&&><and>++<gt><==>

B - spaces in brackets and parens if (XXXXX foo XXXXX)

% Floating point possible

L - blank lines

C - cuddling (else)

Examples:
    C-1       C0        C1       C2
    }         }         }        } else {
  else        else      else {
    {         {

P - parens

% Floating point possible

N - newline

Example: N>e

R - dereferencing

V - variable and sub names

Example of Slash style (incomplete): Vc1a0p(s-1h1a1)

H - habits

What is part of your normal every-script routine? (simply include those that are) Example: Hsw2

End with one of these

Add curlies to main if you put your main logic in a sub: "{main}-sub".


My code:
I4t2 Os1 ;0 S,><.><+>**<=><&&><and>++<gt><==> B1 L1 C2 P-1 N>e R2 Vl(en,nl)c1a1p(s-1h0a1)r0d2 Hsw2 sub-main
I'd like to know yours :)

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk


In reply to Style geekcode by Juerd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":