Whether you like to hug the open brace (example 1) or put it's on it's own line (example 2) is a matter of personal preference - both are correct. However, you really need to line the closing brace up with what started it.

Lining up the braces with keywords is also a matter of personal style. I do it and I wish every one did. Unfortunately, some people don't. Really, it's all a matter of style and there is no correct or incorrect way to do it. I think the real important thing is consistency.

Also, i recommend using tabs instead of spaces

I strongly disagree with this. Use spaces. Tabs just end up being an additional hassle for the programmer. Tabstops have to be set correctly in order for the code to look good. That's not a huge problem but it is an annoyance. The real problem occurs when a tab-using programmer comes along and modifies source code written by a space-using coder (or vice-versa.)

So, once again the answer is consistency. The reason I advocate spaces is that they are inherently consistent and do not rely on an editor or terminal variable as tabs do. A space is a space is a space whereas a tab is eight spaces or maybe four or perhaps two or possibly three and sometimes six... etc.

I know some people advocate using tabs for indentation and spaces for alignment. In my estimation, that's only half a solution. Worse, it creates its own problems later when the code needs to be maintained.

I'd break my tab key off if I didn't use it for completion in my shell.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: (jeffa) 2Re: Losing or overwritting values by sauoq
in thread Losing or overwritting values by sulfericacid

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.