#!/usr/bin/perl -w
######################################################################
# readcfg.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

open(FILE, "mquote.dat") || die "Cannot open mquote.dat";

while(<FILE>) {

    s/#.*//;          # remove comments
    next if /^\s*$/;  # ignore spaces

    @columns = ();    # delete buffer

    while(/("(?:\\\\|\\"|.)*?")| # "parameter"
           (\S+)                 # or: parameter
          /gx) {
        my $match = $+;          # matching alternative
        if(defined $1) {         # parameter in quotes?
            $match =~ s/^"//;    # remove opening "
            $match =~ s/"$//;    # remove closing "
        }
        $match =~ s#\\\\#\\#g;   # \\ -> \
        $match =~ s#\\"#"#g;     # \" -> "
        push(@columns, $match);  # store
    }

    # output result:

    print shift(@columns), "\n";  # first keyword
    foreach (@columns) {          # remaining entries in the line
        print "    $_\n";
    }
}
close(FILE);

