use strict; use LWP::Simple; use HTML::Parser; use constant DEBUG => 0; my $URI_HOST = 'http://www.example.com'; my $URI_PATH = '/sample/database.nsf'; my $content = get( "$URI_HOST$URI_PATH" ); if( not $content ) { $content = q{

The documentation is unavailable

}; } else { my $new = ''; my %in_tag; my $tag_watch = sub { my $tag = shift; my $in = shift; my $attr = shift; $in_tag{$tag} += $in; return unless $in_tag{script} or $in_tag{body} or grep { $tag eq $_ } qw( script body ) ; my $out = (DEBUG ? '[' : '<') . ($in < 1 ? '/' : '') . $tag; if( $attr ) { my @attr_pair; while( my( $key, $value ) = each %$attr ) { # renormalise things that look like URIs $value =~ s{^($URI_PATH/)}{$URI_HOST$1}; push @attr_pair, qq{$key="$value"}; } $out .= join( ' ', ('', @attr_pair)); } $out .= '>'; $new .= $out; }; my $p = HTML::Parser->new( api_version => 3, start_h => [$tag_watch, "tagname, '+1', attr"], end_h => [$tag_watch, "tagname, '-1'"], text_h => [sub { $new .= $_[0] if $in_tag{script} or $in_tag{body} }, "dtext"], comment_h => [sub { $new .= $_[0] if $in_tag{script} }, "dtext"], ); $p->parse($content); $p->eof(); $content = $new; } # now include $content in a templating/include output mechanism of your choice