Maintainable code (not just perl) is code that some other moderately skilled programmer can pick up and modify _safely_.
To make your code reach this state, you need global definitions of constants, _good_ comments when you do any 'magic'. The example would be that
#display the result;
print $result;
is a waste of disk space.
But commenting round a Schwartzian transform, to a) say what it does, and b) link to example/discussion somewhere on the net, is extremely useful if I'm coming to it, and trying to understand your code.
If I to get out a pad of paper to figure out what you're trying to do, then it doesn't have enough comments.
Consistent style is also important. I don't want to be getting confused by what some code is doing because in some situations you start the 'code block' on the same line, and in others, you start it on the next line.
(It can be dealt with by using something like PerlTidy, but...)
--
It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.