in reply to Re^2: Converting HTML tags to upper case
in thread Converting HTML tags to upper case
It uses HTML::TokeParser::Simple as suggested by marto above. If there is HTML in the air I won't leave home without it. :-)
#!/usr/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my $file = 'home.html'; my $p = HTML::TokeParser::Simple->new($file); my $html; while (my $t = $p->get_token){ if ($t->is_start_tag){ my $tag = '<'. uc $t->get_tag; my $attr = $t->get_attr; my $inline; for my $name (keys %{$attr}){ $inline++, next if $name eq '/'; my $name_value = sprintf " %s=\"%s\"", uc $name, lc $attr->{$nam +e}; $tag .= $name_value; } $tag .= ' /' if $inline; $tag .= '>'; $html .= $tag; } elsif ($t->is_end_tag){ my $tag = sprintf "</%s>", uc $t->get_tag; $html .= $tag; } else{ $html .= $t->as_is; } } print $html;
|
|---|