# 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) (HTM
+L_indent)
#
# input_file and output_file are required.
# command_indent inserts whitespace before the actual Response.Writ
+e 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 = <IN>;
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: $!";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|