Skip to content

Instantly share code, notes, and snippets.

@jyotty
Created February 27, 2009 07:06
Show Gist options
  • Save jyotty/71328 to your computer and use it in GitHub Desktop.
Save jyotty/71328 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
use Apache::Admin::Config;
my $sn2a = {};
find(\&molest, '/etc/httpd/conf/sites');
use Data::Dumper;
print Dumper($sn2a);
sub molest {
if ($File::Find::name =~ m{\.conf$}) {
my $conf = Apache::Admin::Config->new($File::Find::name)
or die $Apache::Admin::Config::ERROR;
for my $vhost ($conf->section(-name => 'VirtualHost')) {
my $key = $vhost->directive(-name => 'ServerName')->value;
$sn2a->{$key} ||= [];
for ($vhost->directive(-name => 'ServerAlias')) {
push @{$sn2a->{$key}}, $_->value;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment