October 2004
Intermediate to advanced
336 pages
6h 27m
English
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).
1. # tab ...Read now
Unlock full access