]>
git.p6c8.net - devedit.git/blob - modules/Config/DevEdit.pm
1 package Config
::DevEdit
;
4 # Dev-Editor - Module Config::DevEdit
6 # Parse the configuration file
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-01-16
19 use base
qw(Exporter);
21 @EXPORT = qw(read_config);
25 # Parse the configuration file
27 # Params: Path to configuration file
29 # Return: Configuration (Hash Reference)
36 open(CF
,"<$file") or croak
("Open $file: $!");
37 read(CF
, my $data, -s
$file);
40 my @lines = split(/\015\012|\012|\015/,$data);
43 foreach my $line(@lines)
45 next if($line =~ /^\s*#/);
46 next if($line !~ /^.+=.+$/);
48 my ($key,$value) = split(/=/,$line,2);
50 # Remove whitespaces at the beginning and at the end
57 croak
"Double defined value '$key' in configuration file '$file'" if($config->{$key});
59 $config->{$key} = $value;
patrick-canterino.de