
xyon
New User
Apr 1, 2008, 7:25 AM
Post #1 of 2
(174 views)
|
|
remove block of text (Apache Virtual hosts config)
|
Can't Post
|
|
Hello all, I've got a task to be done that perl could do very nicely, although I'm just stumped on exactly how to do it. I have a config file like so:
<Location /sessions/ceasar> SSLRequireSSL AllowOverride None Options MultiViews Indexes Allow from all Deny from none AuthName "ceasar" Include /etc/httpd/includes/auth.conf require user ceasar </Location> <Location /sessions/spartan> SSLRequireSSL AllowOverride None Options MultiViews Indexes Allow from all Deny from none AuthName "spartan" Include /etc/httpd/includes/auth.conf require user spartan </Location> I would like to be able to delete an assigned user's config (ie, "ceasar"). I can match on "<Location /sessions/$name>", but am unaware as to how to delete the following 9 lines. Here is what I've got so far:
if ($name) { open(CFGFILE, "$config") or die "$!"; foreach my $line (<CFGFILE>) { if ("$line" = "/<Location /sessions/$name>") { }; }; close CFGFILE; # Below is if I stored the file into an array (or used Tie::File), but not sure # how to delete 9 proceeding lines from the match. # @lines = grep(!/<Location \/sessions\/$name>/, @lines); };
|