perl scriptlet to expand tabs into blanks 2019 by C. Masloch Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 12387 [2019-08-23 23:05:04 +0200 Aug Fri] cp -a test.txt test.cvt && perl -i -e 'our $tabstopwidth = 8; our $replacebool; sub replacefunc { my ($length) = @_; our ($tabstopwidth, $replacebool); s/^((:?[^\t]{$tabstopwidth})*[^\t]{$length})\t/$replacebool = 1; $1." " x ($tabstopwidth - $length)/e; }; while (<>) { do { $replacebool = 0; foreach my $length (0 .. $tabstopwidth - 1) { replacefunc($length); }; } while ($replacebool); } continue { print or die "-p destination: $!\n"; }' test.cvt && od -Ax -tx1z test.cvt; cat test.cvt 12388 [2019-08-23 23:06:40 +0200 Aug Fri] history 4 >> ~/wwwecm/perl-expand-tabs.txt 12389 [2019-08-23 23:12:07 +0200 Aug Fri] cp -a test.txt test.cvt && perl -i -e 'our $tabstopwidth = 8; our $replacebool; sub replacefunc { my ($length) = @_; our ($tabstopwidth, $replacebool); s/^((:?[^\t]{$tabstopwidth})*[^\t]{$length})\t/$replacebool = 1; $1." " x ($tabstopwidth - $length)/e; }; while (<>) { do { $replacebool = 0; foreach my $length (0 .. $tabstopwidth - 1) { replacefunc($length); }; } while (/\t/); } continue { print or die "-p destination: $!\n"; }' test.cvt && od -Ax -tx1z test.cvt; cat test.cvt 12390 [2019-08-23 23:12:33 +0200 Aug Fri] history 4 > ~/wwwecm/perl-expand-tabs.txt