summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Config.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-01-20 05:36:53 +0000
committerfukachan <fukachan>2001-01-20 05:36:53 +0000
commit8df7b14435b051c7d024d2f429d23b69b153fbff (patch)
tree1d6fd33314f558fa758e73ddf6d58328a1402173 /fml/lib/FML/Config.pm
parente59302c983ed288f9365c3826d18e4132f29de69 (diff)
downloadfml8-8df7b14435b051c7d024d2f429d23b69b153fbff.tar.gz
fml8-8df7b14435b051c7d024d2f429d23b69b153fbff.tar.bz2
fml8-8df7b14435b051c7d024d2f429d23b69b153fbff.zip
import loading codes from Standalone.pm
Diffstat (limited to 'fml/lib/FML/Config.pm')
-rw-r--r--fml/lib/FML/Config.pm41
1 files changed, 14 insertions, 27 deletions
diff --git a/fml/lib/FML/Config.pm b/fml/lib/FML/Config.pm
index 024697c3..bf933a8e 100644
--- a/fml/lib/FML/Config.pm
+++ b/fml/lib/FML/Config.pm
@@ -69,45 +69,32 @@ sub overload
sub load_file
{
my ($self, $file) = @_;
- my (@_fml_config) = ();
+ my (@key_order) = ();
+ my $config = \%_fml_config;
# open the $file by using FileHandle.pm
use FileHandle;
my $fh = new FileHandle $file;
if (defined $fh) {
- my ($key, $value, $comment);
+ my ($key, $value, $curkey);
while (<$fh>) {
- # end of postfix format
- last if /^=cut/;
+ last if /^=cut/; # end of postfix format
+ next if /^=/; # ignore special keywords of pod formats
+ next if /^\#/; # ignore comments
# here we go
chop;
- # reset { key => value }
- if (/^\s*$/) {
- if ($key) {
- $_fml_config{$key} = $value;
- }
-
- undef $key; undef $value; undef $comment;
- }
-
- # ignore special keywords of pod formats
- next if /^=/;
-
- if (/^([A-Za-z]\w+)\s+=\s*(.*)/) {
- ($key, $value) = ($1, $2);
-
- # record the keyword order
- push(@_fml_config, $key);
- }
- elsif (/^\s+(.*)/ && $key) {
- $value .= " ".$1;
+ if (/^([A-Za-z0-9_]+)\s+=\s*(.*)/) {
+ my ($key, $value) = ($1, $2);
+ $curkey = $key;
+ $config->{$key} = $value;
+ push(@key_order, $key);
}
- else {
- $comment .= $_;
+ if (/^\s+(.*)/) {
+ $config->{ $curkey } .= " ". $1;
}
}
$fh->close;
@@ -117,7 +104,7 @@ sub load_file
}
# expand variable name e.g. $dir/xxx -> /var/spool/ml/elena/xxx
- _expand_variables( \%_fml_config , \@_fml_config );
+ _expand_variables( $config, \@key_order );
}