#!/usr/bin/perl -s use strict; use Text::TabDB; use utf8::all; our($fs,$rm ,$o); my $coms = not $rm; my $cond = shift or die("usage: tabselect [-fs=#] condition file*\n"); Text::TabDB::tabselect({fs=>$fs,coms=>$coms,($o?(o=>$o):())},$cond,@ARGV); __END__ =head1 NAME tabselect - textual relational databases select =head1 SYNOPSIS tabselect [-fs=#] condition tab* > f iconv -f latin -t utf8 tab1 | tabselect '$F1 eq $F4' =head1 DESCRIPTION condition is a perl expression that may have $id variable with field whose idenfier is "id" $_2 variable with field 2 input should be Unicode UTF8. If no tab are 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 =head1 Conditions syntax Condition follows the Perl syntax for conditions; C<$_1> is the first field; C<$id> is the field corresponding to first line C == Example tabselect '$_2' f.tab capital is defined tabselect '$capital' f.tab the same tabselect 'not $_2' f.tab capital is empty tabselect '$_1 =~ /^P/' f.tab Country starts with 'P' =head1 Options -fs='!' changes the field separator (default calculated from schema (first line) or ":") -o=file output file -rm remove comments (#...), directives (%...) and emptylines (def: keep them untouched) =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut