graff has answered your question. fwiw I find HTML::TokeParser::Simple can, imo, help make this sort of task easier.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TokeParser::Simple;
my $sample_HTML = <<EOD;
<HTML>
blah.
<CDATA>
Just some random whatever. It might have some <b>real</b> HTML like a
+table or CSS styling
or even some <H1>IMPORTANT</H1> words. Maybe even a form <form method=
+post>...</form>
</CDATA>
</HTML>
EOD
my $p = HTML::TokeParser::Simple->new(\$sample_HTML)
or die qq{parse failed\n};
my ($in_cdata, $cdata);
while (my $t = $p->get_token){
$in_cdata++, next if $t->is_start_tag(q{cdata});
$in_cdata--, next if $t->is_end_tag(q{cdata});
next unless $in_cdata;
$cdata .= $t->as_is;
}
print $cdata;
Just some random whatever. It might have some <b>real</b> HTML like a
+table or CSS styling
or even some <H1>IMPORTANT</H1> words. Maybe even a form <form method=
+post>...</form>
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|