Changeset 132
- Timestamp:
- 1999-02-02T22:55:46+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/cfgread.pm
r91 r132 7 7 my ($handle) = @_; 8 8 my $line = ""; 9 my @line = (); 10 my $linecontinues = 0; 9 11 10 12 while (defined($line = <$handle>)) { 11 $line =~ s/^\#.*$//; # remove comments13 $line =~ s/^\#.*$//; # remove comments 12 14 $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"; 15 35 return \@line; 16 36 } 17 37 } 38 18 39 return undef; 19 40 }
Note:
See TracChangeset
for help on using the changeset viewer.