[Omaha.pm] Split Apache conf file into separate files

George Neill georgen at neillnet.com
Fri Mar 2 14:49:14 PST 2007


Jay,

If you didn't already know ... apache ships with a log splitter perl  
script. Might be interesting to compare with what you have.

http://httpd.apache.org/docs/2.2/programs/other.html

Later,
George.



Quoting Jay Hannah <jay at jays.net>:

>
> By request today...
>
> j
>
>
> #!/usr/bin/perl
>
> my $read_this_file = "./vhosts.conf";
>
> # Read an Apache conf file w/ multiple VirtualHost directives and
> # split each VirtualHost into a separate file.
> #
> # This'd be cleaner w/ an XML parser (*cough* XML::Twig), but I don't
> # know if the user has any XML libraries installed.
> #
> # 2007-03-02 | Omaha Perl Mongers | http://omaha.pm.org
>
> $/ = '</VirtualHost>';
> open (IN, $read_this_file) or die "Unable to open $read_this_file";
> while (<IN>) {
>     s/.*(<VirtualHost)/$1/s;
>     my ($server_name) = /ServerName (.*)/;
>     next unless $server_name;
>     open (OUT, ">$server_name.conf") or die "Unable to write to   
> $server_name.conf";
>     print OUT $_;
>     close OUT;
> }
> close IN;
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
> !DSPAM:45e8a296243457785049143!
>
>




More information about the Omaha-pm mailing list