7 mrkv2td - Transform multi-record key-value (MRKV) stream to tabular data format.
11 As tabular data format presents field names at the start of transmission,
12 mrkv2td(1) infers them only from the first record,
13 so no need to buffer the whole dataset to find all fields,
14 and it's usual for all records to have all fields anyways.
20 =item -s, --separator I<REGEXP>
22 Regexp which separates field name from cell data in MRKV stream.
23 Default is TAB (C<\t>).
25 =item -g, --multiline-glue I<STRING>
35 $OptSeparatorRegexp = "\t";
36 $OptMultilineGlue = "\n";
38 's|separator=s' => \
$OptSeparatorRegexp,
39 'g|multiline-glue=s' => \
$OptMultilineGlue,
43 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
44 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
54 print join($FS, map {escape_tabdata
($_)} sort { $colnum->{$a} <=> $colnum->{$b} } keys %$colnum).$RS;
58 print join($FS, map { escape_tabdata
($record->{$_}) } sort { $colnum->{$a} <=> $colnum->{$b} } keys %$record).$RS;
67 while(my $line = <STDIN
>)
74 flush_record
(\
%ColumnNumber, \
%record);
81 my ($field, $cell) = split /$OptSeparatorRegexp/, $line, 2;
82 if(exists $record{$field})
84 $record{$field} .= $OptMultilineGlue . $cell;
88 $record{$field} = $cell;
93 push @Headers, $field;
94 $ColumnNumber{$field} = $#Headers;
101 flush_record
(\
%ColumnNumber, \
%record);