I wanted to do a search and replace at the command line, but it didn't work, even though the same regular expression worked in my cgi-bin. Could somebody tell me why the substitution in the first script doesn't replace anything in the file, while the one in the second script does? The file I'm attemting to change with these test scripts is at http://www.polisource.com/documents/BackgroundNotes/TEST/1831pf.shtml .---------------------- Script 1 (doesn't work) ----------------------
#!/usr/local/bin/perl system ('cd [full Unix path to the directory http://www.polisource.com/documents/BackgroundNotes/TEST/ ];find * -name \'1831pf.shtml\' ¦ xargs perl -pi -e "s/\<body\>.*\<\!\-\-\#include virtual\=\"\/cgi\-bin\/Banner\_BackgroundNotes\.pl\" \-\-\>\<br\>/\<body style \= \"margin\-top\: 1px\; padding\-top\: 1px\;\"\>\n\n\<p style \= \"text\-align\: center\; margin\-top\: 1px\; padding\-top\: 1px\;\"\>\n\<a href \= \"http\:\/\/www\.example\.org\"\>\n\<img style \= \"margin\-bottom\: 20px\; border\: none\;\" src \= \"http\:\/\/www\.example\.com\/images\/Banner\_BackgroundNotes\.gif\"\>\n\<\/a\>\n\<\/p\>\n\n\<br\>/s;"');---------------------- Script 2 (works) ----------------------
#!/usr/local/bin/perl $Direc = [full Unix path to the file http://www.polisource.com/documents/BackgroundNotes/TEST/1831pf.shtml ]"; open(IN, $Direc); @file = <IN>; close IN; $Webpage = join ("", @file); $Webpage =~ s/\<body\>.*\<\!\-\-\#include virtual\=\"\/cgi\-bin\/Banner_BackgroundNotes\.pl\" \-\-\>\<br\>/\<body style = \"margin\-top: 1px\; padding\-top: 1px\;\"\>\n\n\<p style = \"text\-align: center\; margin\-top: 1px\; padding\-top: 1px\;\"\>\n\<a href = \"http:\/\/www\.example\.org\"\>\n\<img style = \"margin\-bottom: 20px\; border: none\;\" src = \"http:\/\/www\.example\.com\/images\/Banner_BackgroundNotes\.gif\"\>\n\<\/a\>\n\<\/p\>\n\n\<br\>/s; open(LOG, ">$Direc"); print LOG "$Webpage"; close(LOG);-----------------------
The first script worked only when I shortened the regex to just replace the word "head" with a different word, but if the long regex works in the second script, I don't see why it won't work in the first.Barry
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.2/52 - Release Date: 7/19/2005 --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx