7 @EXPORT = qw(expand unexpand $tabstop);
9 use vars qw($VERSION $tabstop $debug);
23 1 while s/(^|\n)([^\t\n]*)(\t+)/
25 ($tabstop * length($3)
26 - (length($2) % $tabstop)))
29 return @l if wantarray;
42 @lines = split("\n", $x, -1);
44 $line = expand($line);
45 @e = split(/(.{$tabstop})/,$line,-1);
47 $lastbit = '' unless defined $lastbit;
49 if $lastbit eq " "x$tabstop;
54 print "sub on '$x'\n";
58 $line = join('',@e, $lastbit);
60 $x = join("\n", @lines);
62 return @l if wantarray;
72 Text::Tabs -- expand and unexpand tabs per the unix expand(1) and unexpand(1)
79 @lines_without_tabs = expand(@lines_with_tabs);
80 @lines_with_tabs = unexpand(@lines_without_tabs);
84 Text::Tabs does about what the unix utilities expand(1) and unexpand(1)
85 do. Given a line with tabs in it, expand will replace the tabs with
86 the appropriate number of spaces. Given a line with or without tabs in
87 it, unexpand will add tabs when it can save bytes by doing so. Invisible
88 compression with plain ascii!
92 expand doesn't handle newlines very quickly -- do not feed it an
93 entire document in one string. Instead feed it an array of lines.
97 David Muir Sharnoff <muir@idiom.com>