Tyler wrote:

> Hello everyone,
> 
> I'm just starting perl.  I want to search through
> httpd.conf and get the
> ServerName from each virtual host.
> Ex:
> <VirtualHost *>
>         DocumentRoot /home2/ploo.net/www
>         ServerName www.ploo.net
>         CustomLog /home2/ploo.net/logs/access_log
>         ErrorLog /home2/ploo.net/logs/error_log
>         TransferLog
> /home2/ploo.net/logs/transfer_log
>         ScriptAlias /cgi-bin/
> /home2/ploo.net/cgi-bin/
> </VirtualHost>
> <VirtualHost *>
>         DocumentRoot /home2/test.net/www
>         ServerName www.test.net
>         CustomLog /home2/test.net/logs/access_log
>         ErrorLog /home2/test.net/logs/error_log
>         TransferLog
> /home2/test.net/logs/transfer_log
>         ScriptAlias /cgi-bin/
> /home2/test.net/cgi-bin/
> </VirtualHost>
> 
> Could I get the ServerName values put into an array
> so I can do something
> with each different ServerName?  Thank you everyone.
> 
> Tyler

Try this:

-------------------------
open(FILE, "httpd.conf");
while (<FILE>) {
        push(@server_names, $1) if /ServerName\s+(.*)/
}
close FILE;
-------------------------

Now the array @server_names holds the values you want.

HTH


=====
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to