#!/usr/bin/env perl use strict; use warnings; my $N_SPACES = $ARGV[0] || 4; while (my $line = ) { # 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"; }