On Fri, 15 Feb 2002 at 00:42 GMT, Jason Lamar wrote:
> I purchased a "Mail This Page To A Friend" script that I'm doing some
> tweaking on, but I can't figure out a particular item in the function that
> parses HTML code to be formatted into a standard e-mail message.
<snip>
> ... so that only the Image Description is left. Basically, I want to delete
> all the rest of the code but leave the "alt" tag information intact.

use a proper HTML parsing tool to do that for you. HTML::Parser is quite
easy to use with little practice.

#!/usr/bin/perl -w
use strict;
use HTML::Parser 3;

my $html = <<'_HTML_';
<p>Hello <img src="/gifs/earth.gif" with="30" height="30" alt="World"
/>!</p>
_HTML_

HTML::Parser->new(
    report_tags => ['img'],
    start_h     => [ sub { print shift->{alt} }, 'attr' ],
    text_h      => [ sub { print shift }, 'dtext' ],
)->parse($html);

__END__

-- 
briac
 << dynamic .sig on strike, we apologize for the inconvenience >>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to