in reply to How to replace Tab with spaces not altering postion
No modules and quicker than a regex, faster than a speeding bullet, makes you popular with the girls....:)
#! perl -sw use strict; my $tabn = 8; my $tabc = '.'; #! Use a space, '.' is just for demonstration. while( <DATA> ) { print; my $p; substr($_,$p,1) = $tabc x ($tabn - $p % $tabn) while ($p=in +dex($_, "\t"))>-1; print; } __DATA__ the quick brown fox the quick brown fox the brown fox
Gives
c:\test>203941 the quick brown fox the quick brown fox the quick brown fox ........the.....quick...brown...fox the brown fox ................the.............brown...........fox c:\test>
Note: The original data contained tabs....honest! I just couldn't think of an easy way to show them.
Note 2: If it doesn't look like the output is correct, you are probably viewing it with a proportional font.
|
---|