7 untabularize - Revert the formatting done by tabularize(1)
11 untabularize [I<OPTIONS>]
31 use Getopt
::Long qw
/:config no_ignore_case no_bundling no_getopt_compat no_auto_abbrev require_order/;
32 use List
::MoreUtils qw
/all any none/;
35 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
37 use open ':std', ':encoding(UTF-8)';
40 'help' => sub { pod2usage
(-exitval
=>0, -verbose
=>99); },
41 '<>' => sub { unshift @ARGV, @_[0]; die '!FINISH'; },
42 ) or pod2usage
(-exitval
=>2, -verbose
=>99);
48 if(/^(┌|├|└|\+)(.)/ and not @cellWidths)
51 s/^[^\Q$linechar\E]//;
52 s/[^\Q$linechar\E]$//;
53 @cellWidths = map {length} split /[^\Q$linechar\E]/;
65 # pipe char may occur in the cell data as well,
66 # so can not confidentally take it as a cell separator.
67 die "$0: can not determine the columns in --ascii --no-horizontal mode\n";
69 @cellWidths = map {length} split /\Q$gridchar\E/;
72 my $prev_cell_endpos = 0;
73 my @cells = map { s/\s+$// or s/^\s+//; $_ }
74 map { my $cell = substr $record, $prev_cell_endpos, $_; $prev_cell_endpos += $_ + length $gridchar; $cell }
76 print join("\t", @cells) . "\n";