in reply to need advice: Perl code layout, long line lengths

Your question begs another question - what is your audience? If you contributing to a specific project, you may find that it has its own guidelines or rules, so it would therefore be a good idea to enquire. If, on the other hand, you are writing for yourself, write it in such a way that you can read (and understand) it when you come back to it later.

Personally, I cannot understand why so many insist on 80 column lines. How many programmers nowadays still use 80x24 terminals? As I write stuff primarily that nobody else will see, I tend to use 132 column lines. This is perfectly readable in gvim on my 21 inch wide-screen monitor (and I use big fonts) and never wraps when the editor is maximised - which it always is. (And it will still print correctly on an old wide-carriage dot matrix printer ;-)

I also use a 2 column tab setting - this can keep lines to a more sensible length when there are many levels of indent.

To conclude, I'd say work to what your audience wants/expects and if that audience is just you, go with what you are comfortable with and what suits your monitor.

  • Comment on Re: need advice: Perl code layout, long line lengths

Replies are listed 'Best First'.
Re^2: need advice: Perl code layout, long line lengths
by massa (Hermit) on Oct 04, 2008 at 11:09 UTC
    ++ My current terminal is 62x180 (I use YaKuake with 100% width, 100% height). I normally limit the lines to 140 just because after that they become harder to follow (the line breaks normally organize a call to a sub that has a lot of parameters, or a lot of named params) and the extra 40 leave space for other stuff (like to-line-end comments) :-)
    []s, HTH, Massa (κς,πμ,πλ)
Re^2: need advice: Perl code layout, long line lengths
by resistance (Beadle) on Oct 04, 2008 at 12:41 UTC
    Thanks all!

    @smiffy - good question. The code written by me and only I maintain it, but I try to leave it readable as possible for others. I cannot image somebody will print my code on the paper (so I never do).

    @Perlbotics: I thought about replacing with variables too, it could be an option, but it could decrease reading speed too. Thanks for idea replace only a part of parameter.

    I see many of you can accept 132/140 width, so I will do the same, and split the parameter only if it longer then 140 characters.

    Thanks for quick help!