7 td2kvpairs - Transform tabular data into key-value pairs
13 =item -r, --prefix-field I<NAME>
15 Put this field's content before the list of key-value pairs.
17 Prefix and the key-value pairs are separated by a space char,
18 if there is any prefix.
24 td2mrkv(1), kvpairs2td(1)
28 $OptPrefixField = "_REST";
30 'r|prefix-field|prefixfield=s' => \
$OptPrefixField,
34 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
35 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
37 process_header
(scalar <STDIN
>);
41 my @input = read_record
(\
*STDIN
);
43 if(exists $Header{$OptPrefixField})
45 $prefix = $input[$Header{$OptPrefixField}];
46 $prefix =~ s/(\S)$/$1 /;
48 print $prefix . join(' ', map { sprintf "%s=%s", kvpair_escape
($_), kvpair_escape
($input[$Header{$_}]) } grep {$_ ne $OptPrefixField} @Header) . "\n";