Tab Expansion

This function expands tabs in the STDIN passed to it.

The function is passed a numeric tab stop, indicating how many spaces separate each tab. A tab character in the input is expanded out to the correct number of spaces to move the line to the next tab stop.

In Perl, the character "\t" denotes a tab.

Perl's x operator repeats a string a specified number of times:

" " x ($tabwidth - ($cur % $tabwidth));

Therefore, this code repeats the left-side string argument (a single space, in this case) as many times as what's specified by the right side's numeric argument (which is the rest of the glop on that line).

Source Code

						1. # tab ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.