"Style" is subject to concensus. The perl style guide captures consensus within one part of the Perl community at one point in time.

The recommendation to use space around "complex" subscripts is intended to enhace readability. It's easy for the eye to scan   return $foo[$i]; but it's harder to pick out what's going on with something like   return $foo[rand(scalar @foo)]; without adding a bit of whitespace. Many find   return $foo[ rand(scalar @foo) ]; to be more readable. The added whitespace makes it easier to visually scan the subscript.

Vertical whitespace is a related issue. Historically, vertical whitespace was once quite precious: you only got 24 lines of it on most displays. Consensus says to use enough to make things readable, but not too much. The "cuddled else" form (so-called because the else is cuddled between two braces) use one less line than the uncuddled form. Compare

if ( $foo ) { bar(); } else { baz(); }
with
if ( $foo ) { bar(); } else { baz(); }
The cuddled else form uses one less line without (arguably) reducing readability. It's a style issue on which not all agree.

One of the more important aspects of style is consistency. Consider what the Perl style guide has to say, and test it to see if it works for you. Then pick a practice and use it consistently. Readers can adjust to different styles, but inconsistency starts raising red flags.


In reply to Re: style quest by dws
in thread style quest by maddfisherman

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.