It would be really simple to knock up something that did this using HTML::Parser, but it's perhaps worth pointing out that if you are at all interested in XHTML compatibility then valid XHTML tags are all lower case.
Update: Here's a basic HTML::Parser solution. It can almost certainly be improved and/or simplified.
#!/usr/bin/perl use strict; use warnings; use HTML::Parser; my $p = HTML::Parser->new(start_h => [\&start, 'tagname, attr, attrseq +'], end_h => [\&end, 'tagname'], text_h => [\&text, 'text']); $p->parse_file(shift); sub start { my ($name, $attr, $attrseq) = @_; print '<' . uc($name); if (keys %$attr) { foreach (@$attrseq) { print ' ' . uc($_) . '="' . $attr->{$_} . '"'; } } print '>'; } sub end { print '</' . uc($_[0]) . '>'; } sub text { print $_[0]; }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Converting HTML tags into uppercase using Perl
by davorg
in thread Converting HTML tags into uppercase using Perl
by steve_g50
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |