This is the first thing I've written apart from little tutorial excercises, and it was suggested that I post this to SoPW for further advice, so here goes...

All this does is take an HTML file (or any file, really), wrap an ASP Response.Write command around each line, and dump it back out to a file. Nothing fancy, but I'd like to know if there's something I could be doing better.

($infile, $outfile, $indent) = @ARGV; open(IN, $infile) or die "Can't open input file: $!"; open(OUT, ">" . $outfile) or die "Can't open output file: $!"; print "Starting..."; print OUT "<%\n"; while(<IN>) { chomp; print OUT (" " x $indent) . "Response.Write("; if ($_) { print OUT "\"$_\" + "; } print OUT "vbNewLine)\n"; } print OUT "%>\n"; print "Done."; close IN or die "Can't close input file: $!"; close OUT or die "Can't close output file: $!";

And thanks to the chatterbox folks for helping me with the most egregious errors!


In reply to A simple input/output script, suggestions wanted by patgas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.