#!/usr/bin/perl
####################################################################
# A simplistic example of transforming some xml using perl regexps.
###################################################################
# Get the filename to be processed.
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
my $filename = param('filename') || 'sample.html';
# Read in the whole file.
open(INPUT, $filename) or die "couldn't open '$filename'";
undef $/;
my $xmlText = ;
# Modify the file's html tags.
$xmlText =~ s{ <
(/|\?)? # (1) optional / or ? to start tag
(\w+) # (2) the tag name
([^>]*) # (3) anything else without >
>
}{
<
$1
$2
$3
>
}gx;
$xmlText =~ s{
\s*
}{
}mg; # replace two line breaks by one
# And print the formatted html file.
print "Content-type: text/html\n\n";
print "