in reply to Manipulating plaintext within HTML

If you use HTML::TokeParser::Simple, just pass a reference to the variable to the constructor.

use HTML::TokeParser::Simple; my $parser = HTML::TokeParser::Simple->new(\$html); my $new_html = ''; while (my $token = $parser->get_token) { my $text = $token->as_is; $new_html .= $token->is_text ? munge_text($text) : $text; } print $new_html; sub munge_text { # put your text munging stuff here }

Cheers,
Ovid

New address of my CGI Course.
Looking for work. Here's my resume. Will work for food (plus salary).

Replies are listed 'Best First'.
Re: Re: Manipulating plaintext within HTML
by Anonymous Monk on Jun 26, 2003 at 20:33 UTC
    Thanks, thats perfect. :) Your module is pretty nifty.

    (If anyone is curious, I'm matching arbitrary English words with the regex (?<!&)(a-zA-Z'+). The look-behind assertion skips HTML entities, leaving only true English words.)

    Thanks again,

    -jc