acme/bin/t2s

18 lines
296 B
Text
Raw Normal View History

2017-01-26 19:29:57 +03:00
#!/usr/bin/env perl
use strict;
use warnings;
my $N_SPACES = $ARGV[0] || 4;
while (my $line = <STDIN>) {
# Skip empty lines
print "\n" and next if $line !~ m/\S/;
$line =~ m/^(\t*)(.+)$/;
my $n_tabs = length($1);
my $n_spaces = $n_tabs * $N_SPACES;
print ' ' x $n_spaces . "$2\n";
}