#!/usr/bin/perl use Getopt::Long qw(:config no_auto_abbrev no_bundling); use Pod::Usage; my ($help,$man,$fs, $fs2,$f,$the,$baselang,$nfs,$nrs,$e,$o,$ofs,$tagsep,$csv); GetOptions( "help|h|?" => \$help, "man" => \$man, "csv" => \$csv, ## "<>" => sub {push @inputnames, $_[0]}, "fs=s" => \$fs, "tagsep=s" => \$tagsep, "f=s" => \$f, "the" => sub{$f="the"}, "tab" => sub{$f="tab"}, "mul" => sub{$f="tab"}, "baselang=s" => \$baselang, "ofs|nfs=s" => \$nfs, "ors|nrs=s" => \$nrs, "fs2=s" => \$fs2, "e=s" => \$e, "ouput|o=s" => \$o, ## "out|O:s" => \$multiout, ) or die "Specify the --help (or -?) option for usage information.\n"; pod2usage(2) if $help; pod2usage(-exitstatus => 0, -verbose => 2) if $man; use strict; use Text::TabDB; use utf8::all; Text::TabDB::tabconv({format=>$f,fs=>$fs, fs2 => ($fs2 // qr'(?:\||ยง)'), bl=>$baselang, nfs=>$nfs, csv=>$csv, ($e?(e=>$e):()), ($nrs?(nrs=>$nrs):()), ($tagsep?(tagsep=>$tagsep):()), ($o?(o=>$o):())},@ARGV); __END__ =head1 NAME tabconv - convert and pretty-print textual relational databases =head1 SYNOPSIS tabconv [-fs=#] [-f=term] tab* > f iconv -f latin -t utf8 tab1 | tabconv -t=term > f tabconv -nfs=# tab1 (change fs to "#") tabconv -e='perlexp' tab1 =head1 DESCRIPTION =head2 Type of conversions .term (default) ((fname value\n)*\n\n)* .thesaurus|the (baselangvalue\n(fname value\n)*\n\n)* .change fs .perl eval expression (for each tup: eval perlexp($tup))* Input should be Unicode UTF8 If no tab is provided, stdin is used. =head1 FORMATS each input table: country:capital first line - name of the fields Portugal:Lisboa tuple 1 France:Paris tuple 2 Spain:Madrid tuple n Output when format is term: country Portugal capital Lisboa country France capital Paris country Spain capital Madrid =head1 Options -fs='!' changes the field separator (default calculated from schema (first line) or ":") -f=format choose the output format (default "term") f=the f=term (default) f=tab -o=file output file -e='$F1+$F2 . "=$F4"' transform tuples by a perl expression on @F -e='lc($F1) . uc($F2)' format: tab -tab -nfs=# changes the field separator to # -ofs=# idem format: term -tagsep=":" tag separator (default: \t) format: thesaurus -f=the or -the -baselang=en to produce a format of thesaurus ISO... with baselang= en =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut