use Text::Tabs; $tabstop = 8; # set tab spacing to 8 (default) print expand("Hello\tworld"); # convert tabs to spaces in output print unexpand("Hello, world"); # convert spaces to tabs in output $tabstop = 4; # set tab spacing to 4 print join("\n", expand(split(/\n/, "Hello\tworld, \nit's a nice day.\n")));
This module expands tabs into spaces and "unexpands" spaces into tabs, in the manner of the UNIX expand(1) and unexpand(1) programs. All tabs and spaces - not only leading ones - are subject to being expanded and unexpanded.
unexpand() take as argument an array of
strings, which are returned with tabs or spaces transformed. Newlines
may not be included in the strings, and should be used to split
strings into separate elements before they are passed to
$tabstop are imported into
your program when you use this module.