I wanted to separate the source files. (Please do not flame about WHY I would like to turn off my sources. This is not the main thing :-) I could not find usefulness for this. Eclipse did not do this for me, so I implemented my own.
I could not put it in one liner (-e) program. I came with the following, which worked great.
while( <> ) { while( /\t/ ) { s/^(([^\t]{4})*)\t/$1 /; s/^((([^\t]{4})*)[^\t]{1})\t/$1 /; s/^((([^\t]{4})*)[^\t]{2})\t/$1 /; s/^((([^\t]{4})*)[^\t]{3})\t/$1 /; } print; }
However, this makes me wonder if Perl, the champion word processing language, is the right tool. The code does not seem very elegant. If I had to select a source assuming tab = 8 spaces, the code would look even worse.
In particular, because I can think of a deterministic state machine with 4 states to do the job.
I have the feeling that there is a more elegant solution. Am I missing the Perl idiom? In the spirit of TIMTOWTDI, I am interested in other ways to do this.
and.
source share