Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libhtml-parser-perl / libhtml-parser-perl-3.56 / eg / hlc
1 #!/usr/bin/perl -w
2
3 use strict;
4 use HTML::Parser ();
5
6 HTML::Parser->new(start_h   => [ \&start_lc, "tokenpos, text" ],
7                   end_h     => [ sub { print lc shift }, "text" ],
8                   default_h => [ sub { print shift }, "text" ],
9                  )
10     ->parse_file(shift) || die "Can't open file: $!\n";
11
12 sub start_lc {
13     my($tpos, $text) = @_;
14     for (my $i = 0; $i < @$tpos; $i += 2) {
15         next if $i && ($i/2) % 2 == 0;  # skip attribute values
16         $_ = lc $_ for substr($text, $tpos->[$i], $tpos->[$i+1]);
17     }
18     print $text;
19 }
20