[ILUG] PERL -> ASP
Aengus
ilug at linux.ie
Wed Jun 12 11:38:42 IST 2002
Mark Finlay <sisob at eircom.net> wrote:
> I know most people wont touch ASP with a 10 foot pole,
> but I'm stuck trying to modify an asp frontend. It's
> designed to allow input into a propriatary database system,
> and I have about 20000 items to add so i'd rather input it from
> a file.
>
> Can anyone convert this perl to ASP:
ASP isn't a language, it's a framework. You can write Active Server
Pages in any language that you have a scripting engine for. IIS ships
with VBScript and JScript, but ActiveState provides an perl engine, and
you can get TclScript from Sourceforge, Win32 Python installs as an
ActiveX scripting engine, REXX from various commercial providers, etc.
To tell the scripting host which engine to use, just specify the
language in the header, eg:
<SCRIPT LANGUAGE="PerlScript">
> #!/usr/bin/perl
> $i = 0;
> open(SVERSION,"Book1.csv");
>
> while ($line = <SVERSION>)
> {
> if ($line =~ /^(.+?);(.+?);(.+?)$/)
> {
> $i = $i + 1;
> $var1[$i] = $1;
> $var2[$i] = $2;
> $var3[$i] = $3;
> }
> }
> close (SVERSION);
If you can't install ActiveState perl on the box, then the following
VBscript code should do the job:
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.OpenTextFile("Book1.csv")
i=0
Do While tf.AtEndOfStream <> True
ss = split(tfReadLine, ";", -1)
i = i + 1
var1(i) = ss(0)
var2(i) = ss(1)
var3(i) = ss(2)
Loop
tf.Close
This should work as either a script that you can run at the command
line, or as an ASP page (if you enclose it in <% ... %>)
Aengus
More information about the ILUG
mailing list