use HTML::Parser;
use HTML::Entities;
HTML::Parser->new(
default_h =>
[sub {
print shift;
}, "text"],
start_h =>
[sub {
local ($text, $tag,$attr) = shift;
if ($tag eq "img") {
$attr->{src} = Lurker::pick_random( 'IMAGES' );
$text = "<$tag";
$text .= " $_=\"" . encode_entities($attr->{$_}). "\""
for keys %$attr;
$text .= ">";
}
print $text;
}, "text,tag,attr"],
)->parse_file($doc);