in reply to Converting HTML tags into uppercase using Perl
use strict; use warnings; use HTML::TokeParser; my $p = HTML::TokeParser->new( "file.html" ); while ( my $t = $p->get_token ) { #forward comments, text and declarations if ( $t->[0] =~ /[CDT]/ ) { print $t->[1]; } #uppercase start tags elsif ( $t->[0] =~ /S/ ) { print "<", uc($t->[1]), " ", join (" ", map { uc($_) . '="' . $t->[2]->{$_} . '"' } @{$t- +>[3]}), ">"; } #uppercase end tag elsif ( $t->[0] =~ /E/ ) { print uc($t->[2]); } #forward processing instruction elsif ( $t->[0] =~ /PI/ ) { print $t->[2]; } }
|
|---|