Changeset 132


Ignore:
Timestamp:
1999-02-02T22:55:46+13:00 (25 years ago)
Author:
rjmcnab
Message:

Enabled the configuration files to be more readable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/cfgread.pm

    r91 r132  
    77    my ($handle) = @_;
    88    my $line = "";
     9    my @line = ();
     10    my $linecontinues = 0;
    911
    1012    while (defined($line = <$handle>)) {
    11     $line =~ s/^\#.*$//; # remove comments
     13    $line =~ s/^\#.*$//;   # remove comments
    1214    $line =~ s/\cM|\cJ//g; # remove end-of-line characters
    13     if ($line =~ /\w/) {
    14         my @line = split(/\t/, $line);
     15    $line =~ s/^\s+//;     # remove initial white space
     16    $linecontinues = $line =~ s/\\$//;
     17    while ($line =~ s/\s*(\"[^\"]*\"|\'[^\']*\'|\S+)\s*//) {
     18        if (defined $1) {
     19        # remove any enclosing quotes
     20        my $entry = $1;
     21        $entry =~ s/^([\"\'])(.*)\1$/$2/;
     22
     23        # substitute an environment variables
     24        $entry =~ s/\$(\w+)/$ENV{$1}/g;
     25        $entry =~ s/\$\{(\w+)\}/$ENV{$1}/g;
     26
     27        push (@line, $entry);
     28        } else {
     29        push (@line, "");
     30        }
     31    }
     32
     33    if (scalar(@line) > 0 && !$linecontinues) {
     34#       print STDERR "line: \"" . join ("\" \"", @line) . "\"\n";
    1535        return \@line;
    1636    }
    1737    }
     38
    1839    return undef;
    1940}
Note: See TracChangeset for help on using the changeset viewer.