#!/usr/bin/perl
#
# comment_strip        - SHADOW Version 1.7
#                        Last changed 07 Mar 2001
#
#
# Read a file and remove the comments (everything after a #), blank lines,
# and trailing whitespace characters. The parameter is the name of a file.
# Output is written to stdout.
#
# Written by Bill Ralph - 17 October 2000
#
#
sub usage {
        print "Usage: comment_strip FILE_NAME\n";
        exit 2;
}
#
#  Check parameter validity.
#
$file = $ARGV[0];
if ("$file" eq "")
{
        usage();
}
#
#
open(ANO, "<$file");
while (<ANO>) {
   chomp($_);                         # Remove new line
   $_ =~ s/#.*//;                     # Remove everything right of #
   $_ =~ s/\s+$// if ($_);            # Remove trailing whitespace
   next if (! $_);
   print STDOUT "$_\n";
}
close(ANO);
#
