Changed structure of perl modules to be more useful.
[licom.git] / lib / LiCoM / Config.pm
1 package LiCoM::Config;
2
3 use strict;
4 use warnings;
5
6 use Exporter;
7
8 @LiCoM::Config::EXPORT_OK = ('get_config');
9 @LiCoM::Config::ISA = ('Exporter');
10
11 return (1);
12
13 sub get_config
14 {
15         my $file = @_ ? shift : '/etc/licom/licom.conf';
16         my $fh;
17         my $config = {};
18
19         open ($fh, "< $file") or die ("open ($file): $!");
20         for (<$fh>)
21         {
22                 chomp;
23                 my $line = $_;
24
25                 if ($line =~ m/^(\w+):\s*"(.+)"\s*$/)
26                 {
27                         my $key = lc ($1);
28                         my $val = $2;
29
30                         $config->{$key} = $val;
31                 }
32         }
33
34         close ($fh);
35
36         return ($config);
37 }