1Text::Tabs(3) User Contributed Perl Documentation Text::Tabs(3)
2
3
4
6 Text::Tabs - expand and unexpand tabs like unix expand(1) and
7 unexpand(1)
8
10 use Text::Tabs;
11
12 $tabstop = 4; # default = 8
13 @lines_without_tabs = expand(@lines_with_tabs);
14 @lines_with_tabs = unexpand(@lines_without_tabs);
15
17 Text::Tabs does most of what the unix utilities expand(1) and
18 unexpand(1) do. Given a line with tabs in it, "expand" replaces those
19 tabs with the appropriate number of spaces. Given a line with or
20 without tabs in it, "unexpand" adds tabs when it can save bytes by
21 doing so, like the "unexpand -a" command.
22
23 Unlike the old unix utilities, this module correctly accounts for any
24 Unicode combining characters (such as diacriticals) that may occur in
25 each line for both expansion and unexpansion. These are overstrike
26 characters that do not increment the logical position. Make sure you
27 have the appropriate Unicode settings enabled.
28
30 The following are exported:
31
32 expand
33 unexpand
34 $tabstop
35 The $tabstop variable controls how many column positions apart each
36 tabstop is. The default is 8.
37
38 Please note that "local($tabstop)" doesn't do the right thing and
39 if you want to use "local" to override $tabstop, you need to use
40 "local($Text::Tabs::tabstop)".
41
43 #!perl
44 # unexpand -a
45 use Text::Tabs;
46
47 while (<>) {
48 print unexpand $_;
49 }
50
51 Instead of the shell's "expand" command, use:
52
53 perl -MText::Tabs -n -e 'print expand $_'
54
55 Instead of the shell's "unexpand -a" command, use:
56
57 perl -MText::Tabs -n -e 'print unexpand $_'
58
60 This module comes in two flavors: one for modern perls (5.10 and above)
61 and one for ancient obsolete perls. The version for modern perls has
62 support for Unicode. The version for old perls does not. You can tell
63 which version you have installed by looking at $Text::Tabs::SUBVERSION:
64 it is "old" for obsolete perls and "modern" for current perls.
65
66 This man page is for the version for modern perls and so that's
67 probably what you've got.
68
70 Text::Tabs handles only tabs ("\t") and combining characters ("/\pM/").
71 It doesn't count backwards for backspaces ("\t"), omit other non-
72 printing control characters ("/\pC/"), or otherwise deal with any other
73 zero-, half-, and full-width characters.
74
76 Copyright (C) 1996-2002,2005,2006 David Muir Sharnoff. Copyright (C)
77 2005 Aristotle Pagaltzis Copyright (C) 2012-2013 Google, Inc. This
78 module may be modified, used, copied, and redistributed at your own
79 risk. Although allowed by the preceding license, please do not
80 publicly redistribute modified versions of this code with the name
81 "Text::Tabs" unless it passes the unmodified Text::Tabs test suite.
82
83
84
85perl v5.32.1 2021-01-27 Text::Tabs(3)