zone-ls.pl
branchhs12
changeset 71 e25fc893e203
parent 60 2c45d68844bf
child 72 d3d2108f07da
--- a/zone-ls.pl	Mon Jan 03 16:13:54 2011 +0100
+++ b/zone-ls.pl	Mon Jan 03 16:49:56 2011 +0100
@@ -9,6 +9,7 @@
 use Time::Local;
 use Getopt::Long;
 use if $ENV{DEBUG} => "Smart::Comments";
+use my::Config qw(get_config);
 
 my %config;
 my $opt_expiry = undef;
@@ -28,20 +29,7 @@
         },
     ) or pod2usage;
 
-    {    # find and read/parse the config (could use some common config parser)
-        my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
-        ($_) = grep { -f } @configs;
-        open(my $config, $_) or die "Can't open $_: $!\n";
-
-        while (<$config>) {
-            chomp;
-            s/#.*//;
-            s/\s//g;
-            my ($k, $v) = split(/\s*=\s*/, $_, 2) or next;
-            $config{$k} = $v;
-        }
-    }
-
+    %config = get_config("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
     die "$config{master_dir}: $!\n" if not -d $config{master_dir};
 
     foreach my $dir (grep { -d } glob "$config{master_dir}/*") {
@@ -101,14 +89,13 @@
         }
     }
 
-
     {    # output
 
         my $sort_by =
           $opt_expiry
           ? sub { ($info{$a}{expiry} // 2**64) <=> ($info{$b}{expiry} // 2**64) }
           : sub { $a cmp $b };
-		 
+
         my $format_h = "%-35s %-8s %1s/%1s %3s %7s\n";
         my $format_l = "%-35s %-8s %1d/%1d %5d %19s\n";
 
@@ -121,7 +108,6 @@
     }
 }
 
-
 __END__
 
 =head1 NAME