]>
git.p6c8.net - devedit.git/blob - modules/Config/DevEdit.pm
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-06-09
21 use base
qw(Exporter);
23 @EXPORT = qw(read_config);
27 # Read the configuration files of Dev-Editor
29 # Params: Path to main configuration file
31 # Return: Configuration (Hash Reference)
37 my $config = parse_config
($file);
39 $config->{'errors'} = parse_config
($config->{'error_file'});
40 $config->{'templates'} = parse_config
($config->{'template_file'});
42 # Parse list of forbidden files
44 if($config->{'forbidden'})
48 foreach my $file(parse_line
('\s+',0,$config->{'forbidden'}))
52 $file = '/'.$file unless($file =~ m
!^/!);
58 $config->{'forbidden'} = \
@files;
66 # Parse a configuration file
68 # Params: Path to configuration file
70 # Return: Configuration (Hash Reference)
77 open(CF
,'<'.$file) or croak
("Open $file: $!");
78 read(CF
, my $data, -s
$file);
81 my @lines = split(/\015\012|\012|\015/,$data);
85 foreach my $line(@lines)
89 next if($line =~ /^\s*#/);
90 next if($line !~ /^\s*\S+\s*=.*$/);
92 my ($key,$value) = split(/=/,$line,2);
94 # Remove whitespaces at the beginning and at the end
101 croak
"Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
103 $config->{$key} = $value;
109 # it's true, baby ;-)
patrick-canterino.de