#! /usr/bin/perl
$RCS_ID = '$Id: mktbl,v 2.3 1992/06/25 22:13:35 hobbs Exp $' ;
($pgm  = $0) =~ s-.*/-- ;
$HelpInfo = <<EOH ;

		    RDB Operator: $pgm

Usage: $pgm [options]

Options:
    -edit    Edit form of output, used primarily by 'etbl'.
    -help    Print this help info.

Makes a file of data in columns (with visible column delimiters) into an
rdbtable.  The column delimeter is the pipe symbol (|).

This operator reads a file via STDIN and writes an rdbtable via STDOUT.
Options may be abbreviated.

$RCS_ID
EOH
#    -sK     K will be the visible column delimiter, which may be multi-char.
#	     Default is '|', e.g. a space, a vertical bar, and a space.
while ( $ARGV[0] =~ /^-/ ) {				# Get args
    $_ = shift ;
    if( /-e.*/ ){ $EDT++ ; next ; }
    if( /-h.*/ ){ print $HelpInfo ; exit; }
    die "Bad arg: $_\n", $HelpInfo ; 
}
while(<>){
    if( $EDT && /^\.\.>>>/ ){ print ; next ; }	# control line
    if( /^#\s|^\s+#/ ){ print ; next ; } 	# comment 
    s/^\s+// ;
    s/\s+$/\n/ ;
    s-\s*\|[ \t]*-\t-g ;
    $_ = "\n" unless $_ ;	# safety valve
    print ;
}
