1lib.modern::Text::Tabs(U3s)er Contributed Perl Documentatliiobn.modern::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 Text::Tabs handles only tabs ("\t") and combining characters ("/\pM/").
61 It doesn't count backwards for backspaces ("\t"), omit other non-
62 printing control characters ("/\pC/"), or otherwise deal with any other
63 zero-, half-, and full-width characters.
64
66 Copyright (C) 1996-2002,2005,2006 David Muir Sharnoff. Copyright (C)
67 2005 Aristotle Pagaltzis Copyright (C) 2012-2013 Google, Inc. This
68 module may be modified, used, copied, and redistributed at your own
69 risk. Although allowed by the preceding license, please do not
70 publicly redistribute modified versions of this code with the name
71 "Text::Tabs" unless it passes the unmodified Text::Tabs test suite.
72
73
74
75perl v5.34.0 2021-08-25 lib.modern::Text::Tabs(3)