Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You will virtually always find situations where you can't indent properly with just tabs alone. Which means that if you work with tabs set at different size the code turns becomes very difficult to deal with.
This could be a problem, but it shouldn't be difficult to eliminate it. In order to do so, even if you use a mix of spaces and tabs to indent (or rather to align things vertically) just always use tabs to indent (that is, to align vertically the left margin of the lines), and reserve the use of spaces to align vertically only the things past the left margin (in the middle of a line, so to say) such as the => symbol in a hash. In other words, never use spaces to align the left margin and reserve their use only to align the things inside a line. Here is an example:
my %a_hash = ( <TAB> very_very_long_key => 1, <TAB> k2 <SPACES> => 2, <TAB> another_k <SPACES> => 3 );
I've personally used (and spread) this convention for years (mainly with languages different from Perl though) and never had a single problem or complaint.
The only problem I can see happens if you want to use a fancier alignment like this:
my %a_hash = ( very_very_long_key => 1, k2 => 2, another_k => 3 );
but frankly I would avoid it (though some people seem to like it).
IMO forcing people to use your indentation is minimal issue
This is true as long as everyone religiously adopt the same, sensible number of spaces (4 could be OK, but not necessarily, see later), but I've seen so many times people who love to indent with just 2 spaces or even with a single space. As for the 4-spaces convention, not everyone agree: for example both the Linux kernel and the Gnome coders recommend to use 8-spaces (tabs) for indentation.

Thanks to their portability, tabs are IMO the only way to to settle this controversy and make everyone happy.


In reply to Re^4: My coding guidelines by emazep
in thread My coding guidelines by Abigail-II

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-12-09 10:29 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (36 votes). Check out past polls.