Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Generating an httpd.conf from http://example.com/perl-status

by hsinclai (Deacon)
on Mar 11, 2009 at 15:03 UTC ( [id://749902]=note: print w/replies, xml ) Need Help??


in reply to Generating an httpd.conf from http://example.com/perl-status

>>I want to end up with output that is just httpd configuration directives without any Perl code left in it.

Does this work?
use strict; use warnings; my $configfile2parse = 'httpd.conf'; my $configfile2check = 'httpd.conf-stripped'; open FH, '<', $configfile2parse or die "cannot open httpd.conf"; my @content = <FH>; close FH; my $opener = qr{<Perl>}; my $closer = qr{</Perl>}; my @httpd_config_only = grep {!(/$opener/sg .. /$closer/sg)} @content; open NH, '>>', $configfile2check or die "cannot open output file"; print NH $_ for @httpd_config_only; close NH; my $result = qx!httpd -S -f /work/$configfile2check!; print $result . $/;

... tests ok here - but I hope I understood your original problem correctly. Another consideration might be separating out the perl code from httpd.conf using the Include directive within the config

Replies are listed 'Best First'.
Re^2: Generating an httpd.conf from http://example.com/perl-status
by Plankton (Vicar) on Mar 11, 2009 at 17:17 UTC
    Thanks for the reply. I am starting to think there isn't a way to do this and I have stated my question poorly. Your solution works great for removing the text between the <Perl> and </Perl> tags but what I want is to see the resulting configuration generated by the Perl code between the tags. Maybe I could use a eval statement to do this.
      Apologies! I certainly did not get that meaning from your original question.... er.. I now see your dilemma :):)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://749902]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found