It is a rare thing when I don't test code I post, usually only trivial stuff gets past the "I should test that" filter.

More importantly, I try and benchmark things against other answers. I always wanna know why/how things work so one day when it does matter that I did it the fast way, my instincts will lead me down the mostly-right path =)

As to formatting, I like compressed code, so I tend to hang the open braces on the main line and indent body only. I ALWAYS use tabs IRL and tend to have my vim set to 3space tabs.

Spacing brackets and parens is becoming a habit as well, I pad inside and out of brackets, braces, and parens that block code, enclose arguments, or create arrays/lists. Never spaces on array brackets or hash keys. Space on both sides of assignments and math is generally a must, excepting a few degenerate cases like $a+0 and the like.

Vertical whitespace is for separating logical blocks of code, especially in long linear sections.

--
$you = new YOU;
honk() if $you->love(perl)


In reply to RE: On Testing and Formatting Code by extremely
in thread On Testing and Formatting Code by jcwren

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.