#!/usr/bin/perl -w use strict; use English; use warnings; use HTML::TokeParser; my $doc = <<EOF; <html> <head> <script language="Javascript"> document.write("Don't forget your </script> tag! It's important!"); </script> </head> <body> This is just some text. </body> </html> EOF my $p = HTML::TokeParser->new(\$doc); my $result; my $skipping = 0; while (my $tok = $p->get_token) { if ($tok->[0] eq 'S') { if (lc($tok->[1]) eq 'script') { $skipping = 1; } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } elsif ($tok->[0] eq 'E') { if (lc($tok->[1]) eq 'script') { $skipping = 0; } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } print 'Result: ', $result, "\n";
| -- | |||||||
|
| ||||||
| ...Nexcerpt...Connecting People With Expertise | |||||||
In reply to Re: Re: Removing Javascript
by Mur
in thread Removing Javascript
by Mur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |