problem in perl replace command with slash (/) in search/replace string
I want to replace "#######" in a file abcdef.pl with "abcd####/####/#####/#####"
regular perl -i -p -e "s/######/abcd####/####/#####/#####/g",abcdef.pl doesnot seem to work due to "/" and "#". Please help me to overcome this problem or guide me the procedure to do the same with file access and edit method Thanks in advance for the response Ramesh |
You will need to escape the slashes:
perl -i -p -e "s/######/abcd####\/####\/#####\/#####/g" |
I think I had given less information, Please check the complete proble.
consider /root/abc.pl containing ########## and I am executing rep.pl containing $ser="##########"; $domain ="newdomain"; $extension="com"; $x = "<VirtualHost www.$domain.$extension>\n\tServerAdmin admin@$domain.$extension\n\tDocumentRoot \/home1\/$domain\/html\n\tServerName www.$domain.$extension\n\tErrorLog logs\/www.$domain.$extension-error_log\n\tCustomLog logs\/www.$domain.$extension-access_log common\n<\/VirtualHost>" $result=`perl -i -p -e 's/$ser/$x/g;',/root/abc.pl`; I am getting a error which says something like this --------------------------------------------------- "Bareword found where operator expected at -e line ..., near "DocumentRoot".... (Might be a runaway multi-line // string on line 1) (Do you need to predeclare DocumentRoot?) Can any on esove this problem? Regards, Ramesh. P. S |
I'm no expert, but it looks like you're missing a ";" after "...common\n<\/VirtualHost>"
|
replacement probmel in perl
Quote:
(;) doesnt seem to have any significance near "<\/VirtualHost>", I tried different combinations but the result remains same. Can you please check the code again? Regards, Ramesh |
All times are GMT -5. The time now is 03:03 AM. |