#
# Read and parse the configuration files
#
-# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-11-24
+# Author: Patrick Canterino <patrick@patshaping.de>
+# Last modified: 2005-01-06
#
use strict;
my $file = shift;
local *CF;
- open(CF,"<".$file) or croak("Open $file: $!");
+ open(CF,'<'.$file) or croak("Open $file: $!");
read(CF, my $data, -s $file);
close(CF);
my @lines = split(/\015\012|\012|\015/,$data);
my $config = {};
+ my $count = 0;
foreach my $line(@lines)
{
+ $count++;
+
next if($line =~ /^\s*#/);
- next if($line !~ /^.+=.+$/);
+ next if($line !~ /^\s*\S+\s*=.*$/);
my ($key,$value) = split(/=/,$line,2);
$value =~ s/^\s+//g;
$value =~ s/\s+$//g;
- croak "Double defined value '$key' in configuration file '$file'" if($config->{$key});
+ croak "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
$config->{$key} = $value;
}