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
- s => same line
- n => new line
- i => indented
- % <i => indented, but less than the following block
- 0 => no space before
- 1 => space before
Example: on the same line and space before:
Os1
; - semicolon
- 0 => no space before
- 1 => space before
- 2 => line up semicolons
S - whitespace around operators
Add signs to the following items. The possible signs are (with X as the item):
- <X => space before
- X> => space after
- <X> => space on both sides
- % X => no space around this operator
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
- 0 => never
- 1 => only around complex things
- 2 => always
- 3 => more spaces indicates lower precedence
L - blank lines
- 0 => never
- 1 => between chunks
- 2 => more blank lines means more different chunks
C - cuddling (else)
- -1 => fully uncuddled and un-indented more than the curlies
- 0 => uncuddled
- 1 => half cuddle
- 2 => full cuddle
Examples:
C-1 C0 C1 C2
} } } } else {
else else else {
{ {
P - parens
% Floating point possible
- -1 => I always try to avoid them
- 0 => I don't really care, as long as it works
- 1 => I always use parens
- 2 => I'm extremely cautious
- 3 => I'm paranoid: if ((($foo > $bar) && ($baz < $xyzzy)))
N - newline
- < => before operator
- > => after operator
- e => I make an exception for qw(and or || &&) and such
Example:
N>e
R - dereferencing
- -1 => I prefer ${ $foo }{bar}
- 0 => I prefer $$foo{bar}
- 1 => I prefer $foo->{bar}
- 2 => I wish there were a way to dereference the entire thing with an arrow
V - variable and sub names
- % l - language
Put the language(s) in parens, and separate with comma's. Most frequently used language first. Use ISO 639 2-letter codes. (Example for "mostly english, but dutch sometimes): l(en,nl)
- c - caps
- 1 => perl-like: long_names_like_this
- 2 => studdlycaps: LongNamesLikeThis
- 3 => java-like: longNamesLikeThis
- a - abbreviation
- 0 => i never abbreviate
- 1 => sometimes
- 2 => i even use "ary" instead of "array"
- 3 => my variable names are never longer than five characters
- p - plurality (put its arguments in parens)
(-1: never, 0: sometimes, 1: always)
- s - scalar names
- h - hash names
- a - array names
- r - references
- 0 => I don't include "ref" in the name
- 1 => I do include "ref" in the name
- 2 => I even call them "arrayref", "aryref" or "aref"
- d - dummy names
- 0 => % I name them a single letter
- 1 => I call them "dummy" %, "temp" or something like that
- 2 => I use "foo" and friends
Example of Slash style (incomplete):
Vc1a0p(s-1h1a1)
H - habits
What is part of your normal every-script routine?
(simply include those that are)
- s - use strict
- w - use warnings(1) or -w(2)
- T - tainting on
- d - use diagnostics
- % a - $|++
Example:
Hsw2
End with one of these
- main-sub => main code before subs
- sub-main => subs first, main code at the end
- main => ALL subs are in external files
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