diff options
author | Florian Pritz <bluewind@xinu.at> | 2012-12-30 20:49:01 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2012-12-30 20:49:01 +0100 |
commit | 30fa1c6d89f84fe41b6674d3713d7b6af3bc75d8 (patch) | |
tree | 62692f27bd53f8d44e6d91e4ed46d1eaaf0c9895 | |
parent | 5fea41506ea2778b2908861a391fa4b52457f0b1 (diff) | |
download | bin-30fa1c6d89f84fe41b6674d3713d7b6af3bc75d8.tar.gz bin-30fa1c6d89f84fe41b6674d3713d7b6af3bc75d8.tar.xz |
long-lines.pl: Add tab expansion support
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | long-lines.pl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/long-lines.pl b/long-lines.pl index 3ba4930..d0f0c21 100755 --- a/long-lines.pl +++ b/long-lines.pl @@ -3,28 +3,33 @@ use warnings; use strict; use File::Basename; use Getopt::Std; +use Text::Tabs; my %opt; -getopts("hm:", \%opt); +getopts("hm:t:", \%opt); if (@ARGV == 0 || $opt{h}) { print "usage: ", basename($0), " [options] file(s)...\n\n"; print "Options:\n"; print " -m NUMBER maximum chars tolerated per line (default: 80)\n"; + print " -t NUMBER count \\t as NUMBER chars (default: 4)\n"; print " -h this help\n"; exit 0; } my $max = 80; my $line = 0; +$Text::Tabs::tabstop = 4; $max = $opt{m} if ($opt{m}); +$Text::Tabs::tabstop = $opt{t} if ($opt{t}); for my $file (@ARGV) { open FILE,"<", $file; $line = 0; while (<FILE>) { $line++; + $_ = expand $_; if (length > $max) { print "\"$file\" - line $line: ", length, " chars\n"; } |