#!/usr/bin/perl

#
# dbstripcomments
# Copyright (C) 1991-1998 by John Heidemann <johnh@isi.edu>
# $Id: dbstripcomments,v 1.11 1999/11/23 02:04:29 johnh Exp $
#
# This program is distributed under terms of the GNU general
# public license, version 2.  See the file COPYING
# in $dblibdir for details.
#

sub usage {
	print STDERR <<END;
usage: $0 [-h]

Remove any comments in a file, including the header.  This makes the
file unreadable by other JDB utilities, but perhaps more readable by
humans.

With the -h option, leave the header.

Sample input:
#L      experiment      mean    stddev  pct_rsd conf_range      conf_low       conf_high        conf_pct        sum     sum_squared     min     max     n
experiment:  ufs_mab_sys
mean:        37.25
stddev:      0.070711
pct_rsd:     0.18983
conf_range:  0.6353
conf_low:    36.615
conf_high:   37.885
conf_pct:    0.95
sum:         74.5
sum_squared: 2775.1
min:         37.2
max:         37.3
n:           2

#  | /home/johnh/BIN/DB/dbmultistats experiment duration
#  | /home/johnh/BIN/DB/dblistize 

Sample command:
cat data.jdb | dbstripcomments

Sample output:
experiment:  ufs_mab_sys
mean:        37.25
stddev:      0.070711
pct_rsd:     0.18983
conf_range:  0.6353
conf_low:    36.615
conf_high:   37.885
conf_pct:    0.95
sum:         74.5
sum_squared: 2775.1
min:         37.2
max:         37.3
n:           2

END
	exit 1;
}


BEGIN {
    $dblibdir = "/usr/local/lib/jdb";
    push(@INC, $dblibdir);
}

use DbGetopt;
@orig_argv = @ARGV;
#my($prog) = &progname;
my($leave_header) = undef;
my($dbopts) = new DbGetopt("h?", \@ARGV);
my($ch);
while ($dbopts->getopt) {
    $ch = $dbopts->opt;
    if ($ch eq 'h') {
	$leave_header = 1;
    } else {
	&usage;
    };
};

if ($leave_header) {
    my($h);
    $h = <STDIN>;
    print $h;
}

while (<STDIN>) {
	if ($_ =~ /^\#/) {
#		print $_;
		next;
	};

	print $_;
};

# print "#  | $0\n";
exit 0;

