
fashimpaur
User
Aug 23, 2001, 5:45 AM
Post #4 of 5
(16869 views)
|
Re: how do I delete blocks of code
[In reply to]
|
Can't Post
|
|
Gee, I saw the reply count was up and almost did not stop to see this post. But, curiosity got the best of me and I wanted to see what your question was. I will use backslashes to try to keep the comments from disappearing in the post. Here is the example I tested: my $htmlText = qq~ <h3>Some html</h3> <h4>Don't know what to show</h4> this text is not to be displayed <!-- but here is a comment ending --> This text should show ~; # assume $htmlText is read in line by line from file and stuffed # in array, then Result would be something like: my @html = split(/\n/, $htmlText); my @cleanedHtml; my $hideFlag = 0; while (@html){ $pattern = "\<\!\-\-(.+?)\-\-\>"; my $line = shift @html; if ($hideFlag){ $hideFlag = 0 if $line =~ /$pattern/; next; } if (!$hideFlag){ if ($line =~ /$pattern/){ $hideFlag = 1; next; } else { push @cleanedHtml, $line; } } } print join "\n", @cleanedHtml; Will attach .txt file also. After previewing the post, I am afraid I will miss something in the translation. HTH, Dennis $a="c323745335d3221214b364d545a362532582521254c3640504c37292f493759214b3635554c3040606a0",print unpack"u*",pack "h*",$a,"\n\n"
|