I would not think myself as experienced enough to give well advice, what i learned so far:
Try to write the code the way that others might understand it fast (maybe you find someone who could reread and comment ...).
Read the code a few days later (or weeks) and if you understand it fast thats a good sign.
Use alot of Comments especially on "more complicated code blocks". I try to add a few comment lines at top of the Script to explain to people not knowing perl what my script is doing (or should do ;-)), so these people could know if it might be safe to run it ...(for the sysadmin colleagues ...)
I am no friend of the many "cryptic shortcuts" on perl if the choice is there maybe write a little more if it is better understandable.
Warnings should be generally enabled.
Is a must, since it doesnt "exit|break" like strict.
I am not a friend "of strict using strict" (but you could disable on some code blocks if you want to use it, sometimes i think it makes life a little too hard esp. with $_. But on bigger projects it might help with some common errors, for smaller code snippets its "overkill" i think. So i wouldnt blame people for not using strict ...) Just my 2ct.


In reply to Re: Help with Coding Style by matze77
in thread Help with Coding Style by Seij

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.