Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: HTML To ASP Converter

by $code or die (Deacon)
on Apr 30, 2001 at 23:54 UTC ( #76726=note: print w/replies, xml ) Need Help??

in reply to HTML To ASP Converter

How about this code alternative:
use strict; use File::Basename; my ($name,$path,$suffix) = fileparse($ARGV[0], '\.html?'); unless (($suffix) && (-e $ARGV[0])) { complain() } rename ($ARGV[0], $path . $name . ".asp") && print "File converted to ASP!" or complain(); sub complain { print "Error: Check and try again"; exit; }
Admittedly the error checking could be better and we should use a GetOpt::* module to get the input filename but I think it does the job.

Basically, ignore my previous post because even though you are converting a static htm file to ASP, it will still be slower than regular html on IIS 5 because you are adding unnecessary Response.Write statments. You don't need them at all. You can display static HTML as static html with an ASP extension, you don't need to enclose it all in <% tags. You're making the webserver do more work by having to process the file with asp.dll even on IIS5

Does this make sense?
Update: I don't intend this post to sound harsh, but you are making the HTML very ugly and hard to maintain because each line will be wrapped between Response.Write(?). I also think it will break if you have any text on multiple lines that are between <pre> tags and multi-line text boxes - you'll have an extra carriage return in there, plus vbNewLine - written out.

$code or die
$ perldoc perldoc

Replies are listed 'Best First'.
Re: Re: HTML To ASP Converter
by patgas (Friar) on May 01, 2001 at 00:54 UTC

    Well, I intended it for converting little bits of HTML that get stuck within an actual application. All the benchmarks I've seen show that having an all-ASP page using those long, ugly, concatenated Response.Writes are much faster than mixed HTML/ASP or one Response.Write for each line.

    You're right about straight HTML being faster, though. Like I said, it's meant for bits and pieces (like a <head>) to put into an application. I've been using it mostly to convert tables for a calendar-type app that I hand-coded... I guess this script's purpose needs a little better explanation.

    -- More than perfect! Let us engage the Concord!
      That's strange that it should benchmark that way. I've noticed that VBScript doesn't have anything like Perl's here-doc capability (unless I am missing something), it would be much nicer to be able to do this (I'll give you a PerlScript ASP example):
      $Response->Write(<<SNIPPET); <HTML> <Head> <Title>$title</Title> </Head> <Body> SNIPPET
      This way, the HTML is left alone still. But that's PerlScript for you! - No hard feelings?
      $code or die
      $ perldoc perldoc

        There is no here document but it's not that much of hassle to put script tags and use the = as a shortcut for Response.Write, i.e.

        ' ... ' asp code %> <html> <head> <title><%=title%></title> </head> <body> <% ' more ASP code ' ...

        Admittedly it's a few more characters than perl but not too painful. You can just have plain HTML text in your ASP document outside the script tags.

        None at all. I'd love to move to using Perl for everything, but I've been using VBScript for so long now, that it comes easier to me. Besides, I'm not a "developer" per se, I just write stuff to make my life easier (like this script). I've only been hacking away at Perl for about a month now, and this is the first really non-experimental, usable script I've made, and I was kinda proud of it.

        -- More than perfect! Let us engage the Concord!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://76726]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2020-10-20 20:11 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (210 votes). Check out past polls.