]>
git.p6c8.net - devedit.git/blob - modules/Config/DevEdit.pm
0286f5a1670fb12453e8f117b8a65efe9449bcf1
1 package Config
::DevEdit
;
4 # Dev-Editor - Module Config::DevEdit
6 # Read and parse the configuration files
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-11-24
19 use base
qw(Exporter);
21 @EXPORT = qw(read_config);
25 # Read the configuration files of Dev-Editor
27 # Params: Path to main configuration file
29 # Return: Configuration (Hash Reference)
35 my $config = parse_config
($file);
37 $config->{'errors'} = parse_config
($config->{'error_file'});
38 $config->{'templates'} = parse_config
($config->{'template_file'});
45 # Parse a configuration file
47 # Params: Path to configuration file
49 # Return: Configuration (Hash Reference)
56 open(CF
,"<".$file) or croak
("Open $file: $!");
57 read(CF
, my $data, -s
$file);
60 my @lines = split(/\015\012|\012|\015/,$data);
63 foreach my $line(@lines)
65 next if($line =~ /^\s*#/);
66 next if($line !~ /^.+=.+$/);
68 my ($key,$value) = split(/=/,$line,2);
70 # Remove whitespaces at the beginning and at the end
77 croak
"Double defined value '$key' in configuration file '$file'" if($config->{$key});
79 $config->{$key} = $value;
patrick-canterino.de