Alex,

In article <[EMAIL PROTECTED]>, Alex Stan wrote:
>I need to search for a string in httpd.conf file , ( the string is :
>CustomLog /var/log/httpd/site.com/access_log ) and then replace
>inside them  site.com with site_com. I mentioned that the site.com can take
>diferent values, such as shop.com,radioq.com, etc.
>
>Could you help me?

I think I can!

Here's what I've got for you; hopefully I've properly interpreted your
request!

---begin sample code
#!/usr/bin/perl -w

use strict;

my $old_domain = 'site.com';
my $new_domain = 'radioq.com';
my $string = "CustomLog /var/log/httpd/$old_domain/access_log";

# Just so we can see...
print "Before: $string\n";

# Make a change to this line *if*
#  * This is a CustomLog directive
#    AND
#  * the value of $old_domain appears in it 
# (Depending on your needs, you might want to make
# this second test more specific...)
if ( $string =~ m!^CustomLog! && $string =~ m!$old_domain! ) {
        # If the above two conditions were met, we perform
        # the substitution.
        $string =~ s![\w-]+\.[\w]{3}!$new_domain!;
}

# ...that changes were made.
print "After : $string\n";
---end sample code

HTH,

John
-- 
               John Fox <[EMAIL PROTECTED]>
    System Administrator, InfoStructure, Ashland OR USA
  ---------------------------------------------------------
"What is loved endures.  And Babylon 5 ... Babylon 5 endures."
              --Delenn, "Rising Stars", Babylon 5

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to