]>
git.p6c8.net - devedit.git/blob - modules/Config/DevEdit.pm
7402ff19361a15a0089e2b5491967067e214d36b
1 package Config
::DevEdit
;
4 # Dev-Editor - Module Config::DevEdit
6 # Read and parse the configuration files
8 # Author: Patrick Canterino <patrick@patshaping.de>
9 # Last modified: 2005-01-06
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);
64 foreach my $line(@lines)
68 next if($line =~ /^\s*#/);
69 next if($line !~ /^\s*\S+\s*=.*$/);
71 my ($key,$value) = split(/=/,$line,2);
73 # Remove whitespaces at the beginning and at the end
80 croak
"Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
82 $config->{$key} = $value;
patrick-canterino.de