| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/libhtml-parser-perl/examples/ |
Upload File : |
#!/usr/bin/perl
# This script will assume that the first command line argument
# is a file containing HTML, and return a version
# where all the tags are converted to lowercase.
use strict;
use warnings;
use HTML::Parser ();
HTML::Parser->new(
start_h => [\&start_lc, "tokenpos, text"],
end_h => [sub { print lc shift }, "text"],
default_h => [sub { print shift }, "text"],
)->parse_file(shift)
|| die "Can't open file: $!\n";
sub start_lc {
my ($tpos, $text) = @_;
for (my $i = 0; $i < @$tpos; $i += 2) {
next if $i && ($i / 2) % 2 == 0; # skip attribute values
$_ = lc $_ for substr($text, $tpos->[$i], $tpos->[$i + 1]);
}
print $text;
}