Code

if the perl bindings are to be installed together with rrdtool, make sure INSTALL_BAS...
[rrdtool-all.git] / website / bin / fix-hrefs.pl
1 #!/usr/bin/perl -w
3 use strict;
4 use HTML::Parser;
6 my $p = HTML::Parser->new(api_version => 3);
7 $p->handler(start => \&startsub, 'tagname, text');
8 #$p->handler(end => \&endsub, 'tagname, text');
9 $p->handler(default => sub { print shift() }, 'text');
10 $p->parse_file(shift||"-") or die("parse: $!");
12 sub startsub {
13         my $tag = shift;
14         my $text = shift;
15         
16         if ($tag eq "a") {
17                 $text =~ s,".*?/doc/,",;
18                 $text =~ /^http:/ || $text =~ s,\.html,.en.html,;
19                 $text =~ s/name=".+?"//;
20         }
21         print $text;
22 }