http://qs321.pair.com?node_id=11132820


in reply to Code style question

As a general thing there is no "Right" code style, although there are plenty of wrong styles. Mostly, if you have thought about your style at all and are consistent the results will be pretty good. Looking at your module code it seems likely you have thought about style and are consistent and the results are pretty good.

With that in mind, there is no "Right" indent size. Like several others I mostly settle on 3 spaces (always spaces - never tabs) to indent all my code, except Perl! Because I contribute a reasonable amount of code to PerlMonks my Perl style tends to conform more to Perl norms which include 4 space indents and K&R layout. Like I said, there are no rights and consistency is King (at least within a language).

I also frequently use Perl::Tidy to clean things up after a heavy refactoring session (for example). It is a great tool and can be configured to generate pretty much whatever your preferred coding style is. It can take a while to beat its configuration into the right shape, depending on how far your style is from Perl::Tidy's defaults. But it's worth the effort of doing so that you can be comfortable to bash out some code then quickly tidy it up with Perl::Tidy.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Code style question
by AlexP (Scribe) on May 21, 2021 at 07:56 UTC

    Thanks for you time and comments.

    This is not the first time I've heard about 3 spaces. There is something to think about.