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:
Code not working

 



mscott0
Novice

Mar 25, 2003, 7:54 PM

Post #1 of 2 (355 views)
Code not working Can't Post

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

Basically Im taking the variable $page, and getting all the content between the <%!%WYSIWYG%!%> tags, and replacing it all with $new.... Is this the wrong way to go about it or is there something simple wrong with it?


davorg
Thaumaturge / Moderator

Mar 26, 2003, 1:11 AM

Post #2 of 2 (352 views)
Re: [mscott0] Code not working [In reply to] Can't Post

Seemss to work for me. Here's my test program.

Code
#!/usr/bin/perl 

use strict;
use warnings;

my $page = do { local $/; <DATA> };

my $new = 'the replacement text';

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

print $page;

__END__
Here is some text
<%!%WYSIWYG%!%>something in the text<%!%WYSIWYG%!%>
Some other text.


What problems are you seeing?

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

 
 


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

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