Dangit!!  Just after posting, I noticed that I got the substitution wrong.

THIS

$httpdconf =~
s!<VirtualHost\s+\*>\s+DocumentRoot\s+/var/www/virtual/$ARGV[1]/html.*?</virtualhost>!!;

should be changed to THIS

$httpdconf =~
s!<VirtualHost\s+\*>\s+DocumentRoot\s+/var/www/virtual/$ARGV[1]/html.*?</VirtualHost>!!s;

The "s" added to the end means to treat the whole variable as a single
line, and thus end-of-lines are interpretted as white space.

A little translation, the substitute command in Perl looks like this:

s!match patter!substitution!flags

You can actually use a plethora or separators, not just '!'.  Many people
use '/', but I didn't since they are used so often in the match pattern.

\s means space (newline is included with the 's' flag at the end)
+ means the previous character 1 or more times
* means the previous character 0 or more times
\* means the actual * character
. means any character
*? means to not do "greedy" matching.  For example, if my .*? were
converted to a .*, it would match until the LAST </VirtualHost> in the
file.  with the .*?, it matches until the FIRST one.
$ARGV[X] gets the x'th command-line parameter.

Anyway, everything that is matched in the first part is replaced in the
substitution.

Also, I forget if the first argument is $ARGV[0] or $ARGV[1].  You may try
both.  If you give me a real file, I might be able to code it for you
outright.

Jon




_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to