# HTML2ASP
# By patgas
# April 30, 2001
#
# Takes an HTML file, and converts it into a
# Response.Write command for an ASP page.
#
# Usage:
# perl html2asp.pl [input_file] [output_file] (command_indent) (HTML_indent)
#
# input_file and output_file are required.
# command_indent inserts whitespace before the actual Response.Write command.
# HTML_indent inserts whitespace in the string argument to Response.Write.
my ($infile, $outfile, $indentCommand, $indentHTML) = @ARGV;
die "Missing required argument: $!" if (!$infile || !$outfile);
$indentCommand ||= "2";
$indentHTML ||= "0";
open(IN, $infile) or die "Can't open input file: $!";
open(OUT, ">$outfile") or die "Can't open output file: $!";
print "Starting... ";
select(OUT);
print "<%\n\n";
$indentCommand = ' ' x $indentCommand;
$indentHTML = ' ' x $indentHTML;
my @lines = ;
my $writeCommand = 1;
while (@lines) {
chomp(my $line = shift @lines);
print $indentCommand;
if ($writeCommand == 1) {
print "Response.Write(";
$writeCommand = 0;
}
else {
print " ";
}
print $indentHTML;
if ( $line ) {
$line =~ s/\"/\"\"/g;
print "\"$line\" & ";
}
print "vbNewLine";
if (@lines) {
print " & _";
}
else {
print ")\n";
}
print "\n";
}
print "%>";
print STDOUT "Done.";
close IN or die "Can't close input file: $!";
close OUT or die "Can't close output file: $!";