Tabs vs Spaces. Article about symbols that are used for indentation in 3.8 million Perl files on CPAN

There are 135 thousand releases on CPAN now. In those releases there are about 3.8 million files with extensions .pm, .pl, .t or .pod.

Here is a link with a small research what symbols are used for indentation in all that files.

There is obvious trend, but unfortunately in this article there is no exact answer why it happen.


One explanation for mixed spaces and tabs is laziness, though in the common sense not the Larry Wall sense.

By default, vi and friends indent 4 spaces per level. But they render a tab as 8 spaces. So one level of indentation is four spaces, two are a tab, three are a tab followed by four spaces, and so on.

My suspicion is that a large number of the "both" files fit this pattern.

There are several issues that are not being considered. First off, the code for analysis looks at every line. It should ignore all blank lines, lines that are within POD ( /^=\w+/ .. /^=cut\s*$/ ), all lines that are solely comments ( /^\s*#/ ), anything after __DATA__ or __END__, and, if possible, anything inside a string ("...", '...', <<END_STRING, qq, q, ...).

The analysis code should also count the lines that start with any of the following conditions:

  1. skipped (described above)
  2. no-indentation, /^\S+/
  3. only tabs, /^\t+\S+
  4. only spaces, /^[ ]+\S+/ )
  5. spaces following tabs, /^\t+[ ]+\S+/ )
  6. or mixed tabs and spaces, /^[ \t]*[ ]+\t+\S+/ )
That last category is th one the most problematic one.

IMHO the bloger would of better off spending his time doing a few pull requests and fixing some bugs then spending a bunch of time exaiming the ages old 'tab' vs 'space' debate.

Since the days PC computers got more than 640K of disk space on a floppy it has stopped to be an issue.

In the good old days of 64k many of old farts would argue for 'tabs' as the took only 8 bits of less memory than while '4 spaces' took up 32.

In the big scope of things it really doesn't matter much

Leave a comment

About Ivan Bessarabov

user-pic I blog about Perl.