#!/usr/bin/env perl

# Convert soft-tabs into proper tabs
my $columns = shift() || 2;
while(<>){
	s|^( {$columns})+|"\t" x (length($&)/2)|ge;
	print $_;
}

#!/usr/bin/env perl

# Convert soft-tabs into proper tabs
my $columns = shift() || 2;
while(<>){
	s|^( {$columns})+|"\t" x (length($&)/$columns)|ge;
	print $_;
}

Use option for calculating replacement length
Use option for calculating replacement length
