tabularize auto-pager
[hband-tools.git] / tabdata / td2mrkv
blobdffe9694b7421cf80a622e5ad73be91ce3528849
1 #!/usr/bin/env perl
3 =pod
5 =head1 NAME
7 td2mrkv - Transform tabular data into multi-record key-value (MRKV) format.
9 =head1 OPTIONS
11 =over 4
13 =item -s, --separator I<STR>
15 String to separate field name from content.
16 Default is TAB (C<\t>).
18 =back
20 =head1 EXAMPLE
22 getent passwd | tr : "\t" | td-add-headers USER PW UID GID GECOS HOME SHELL | td-select +ALL -PW | td2mrkv
24 =head1 SEE ALSO
26 mrkv2td(1), td2html(1)
28 =cut
30 $OptSeparator = "\t";
31 %OptionDefs = (
32 's|separator=s' => \$OptSeparator,
35 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
36 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
39 process_header(scalar <STDIN>);
42 while(not eof STDIN)
44 my @Field = read_record(\*STDIN);
46 for my $idx (0..$#Header)
48 printf "%s%s%s\n", $Header[$idx], $OptSeparator, $Field[$idx];
51 print $RS;