CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Editing Webpages

 



mscott0
Novice

Mar 7, 2003, 5:20 PM

Post #1 of 7 (911 views)
Editing Webpages Can't Post

ok, heres the procedure. My script opens a html file, and gets the content between the tags 'body' and stores it in a string. Then loads 'body' into a wysiwyg online editor and then lets you modify it. Now what would be the easiest was to replace the old body on the page, with the "new" body on the page??

header
<%!%WYSIWYG%!%>
body
<%!%WYSIWYG%!%>
footer


davorg
Thaumaturge / Moderator

Mar 10, 2003, 4:38 AM

Post #2 of 7 (899 views)
Re: [mscott0] Editing Webpages [In reply to] Can't Post

Assuming that you have the contents of the page in $page and the new text in $new, then you could do something like

Code
$page =~ s{<%!%WYSIWYG%!%>.*?<%!%WYSIWYG%!%>} 
{<%!%WYSIWYG%!%>$new<%!%WYSIWYG%!%>}m;


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


mscott0
Novice

Mar 13, 2003, 5:26 PM

Post #3 of 7 (892 views)
Re: [davorg] Editing Webpages [In reply to] Can't Post

How do I open the file to do the editing? Do i just delcare the variable or what?


mscott0
Novice

Mar 13, 2003, 7:14 PM

Post #4 of 7 (887 views)
Re: [davorg] Editing Webpages [In reply to] Can't Post

OK, so ive got it opening the file and writing to the file, but this line:

$page =~ s{<%!%WYSIWYG%!%>.*?<%!%WYSIWYG%!%>}
{<%!%WYSIWYG%!%>$new<%!%WYSIWYG%!%>}m;

-isnt working. It doesnt replace anything, everything just stays the same.


davorg
Thaumaturge / Moderator

Mar 14, 2003, 1:40 AM

Post #5 of 7 (884 views)
Re: [mscott0] Editing Webpages [In reply to] Can't Post

Any number of things could be going wrong. It's impossible to help without seeing more of the code.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


mscott0
Novice

Mar 14, 2003, 6:25 PM

Post #6 of 7 (878 views)
Re: [davorg] Editing Webpages [In reply to] Can't Post

OK, heres the code that is supposed to be replacing the old file content with the updated stuff. The inputs DO exist because I've checked on each variable that comes in..


Code
 $new="$form{'box2'}"; 
$file="$form{'file'}";
open(FILE, "../../$file");
@FILE=<FILE>;
$page=join('',@FILE);
$page =~ s{<%!%WYSIWYG%!%>.*?<%!%WYSIWYG%!%>} {<%!%WYSIWYG%!%>$new<%!%WYSIWYG%!%>}m;
close(FILE);
open(FILE, ">../../$file");
print FILE "$page";
close(FILE);



mscott0
Novice

Mar 20, 2003, 9:39 AM

Post #7 of 7 (865 views)
Re: [mscott0] Editing Webpages [In reply to] Can't Post

Does anyone have any other way of replacing old file content with new - like whats explained above??

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives