equal
deleted
inserted
replaced
9 our @EXPORT_OK = qw(get_config); |
9 our @EXPORT_OK = qw(get_config); |
10 |
10 |
11 sub get_config(@) { |
11 sub get_config(@) { |
12 |
12 |
13 # read configuration |
13 # read configuration |
14 my @configs = @_; |
14 my @configs = |
|
15 @_ |
|
16 ? @_ |
|
17 : ( |
|
18 $ENV{DNSTOOLS_CONF}, "dnstools.conf", |
|
19 "$ENV{HOME}/.dnstools.conf", "/etc/dnstools.conf" |
|
20 ); |
15 my %config; |
21 my %config; |
16 |
22 |
17 # the first config FILE |
23 # the first config FILE |
18 my ($_) = grep { -f } @configs; |
24 my ($_) = grep { -f } @configs; |
19 |
25 |
45 DNStools::Config - config parser |
51 DNStools::Config - config parser |
46 |
52 |
47 =head1 SYNOPSIS |
53 =head1 SYNOPSIS |
48 |
54 |
49 use DNStools::Config qw(get_config); |
55 use DNStools::Config qw(get_config); |
|
56 %config = get_config(); |
50 %config = get_config($file1, $file2, ...); |
57 %config = get_config($file1, $file2, ...); |
51 |
58 |
52 =head1 DESCRIPTION |
59 =head1 DESCRIPTION |
53 |
60 |
54 Simple config file parser. The format is simple: |
61 Simple config file parser. The format is simple: |
64 =item B<get_config>(I<list of config files>) |
71 =item B<get_config>(I<list of config files>) |
65 |
72 |
66 Read the first file of the list (or dies if none of the files is found). |
73 Read the first file of the list (or dies if none of the files is found). |
67 Returns a hash with the config keys and values. |
74 Returns a hash with the config keys and values. |
68 |
75 |
|
76 If the list is empty, the configuration file is search in some default |
|
77 locations: C<$DNSTOOLS_CONF>, F<./dnstools.conf>, |
|
78 F<$HOME/.dnstools.conf>, F</etc/dnstools.conf>. |
|
79 |
69 =back |
80 =back |
70 |
81 |
71 =cut |
82 =cut |
72 |
83 |
73 |
84 |