Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Dear Wise Monks,

I have been tasked with translating the startup_cfg.pl file (You know ... the file that gets generated by a call to Apache2::PerlSections->store( $file )) to a config file that uses httpd.conf syntax. I have search CPAN and the web and haven't found what I need. I can't believe that someone hasn't done this before and would like to avoid having to reinvent the wheel here.

Does any Monk know of a module or script that does this?

Thanks!

Replies are listed 'Best First'.
Re: Getting startup_cfg.pl in httpd.conf syntax
by Plankton (Vicar) on Dec 11, 2009 at 22:28 UTC
    I bit the bullet and decided to write something ...
    #!/opt/lampp/bin/perl -w #use strict; use Data::Dumper; require "startup_cfg.pl"; #print Dumper(%VirtualHost); print "RewriteLogLevel $RewriteLogLevel\n"; print "MaxClients $MaxClients\n"; for my $vhost ( keys %VirtualHost ) { foreach my $vhostdir ( $VirtualHost{$vhost} ) { foreach my $el ( @{$vhostdir} ) { print "<VirtualHost $vhost>\n"; foreach my $rec ( keys %{$el} ) { if ( $rec eq "Alias" ) { foreach my $alias ( @{$el->{$r +ec}} ) { print "\tAlias ". (joi +n "\t", @{$alias}) . "\n"; } } elsif ( $rec eq "RewriteRule" ) { foreach my $rule ( @{$el->{$re +c}} ) { print "\tRewriteRule " +. (join "\t", @{$rule}) . "\n"; } } else { print "\t$rec\t" . $el->{$rec} + . "\n"; } } print "</VirtualHost>\n"; } } } print "Timeout $Timeout\n";