Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Need help with PerlScript (asp).

Reply
Thread Tools

Need help with PerlScript (asp).

 
 
Brian
Guest
Posts: n/a
 
      07-14-2004
Hello all. I'm coding a site right now, but I don't know Perl or asp
(other than what I've learned in the last few days). I had someone
helping me write some ASP code, but it is in VBscript, unfortunately
my server only accepts PerlScript. I've converted as much of it as I
can, but it still doesn't work. It's a simple script, and I'm
wondering if someone can look it over and tell me what's wrong (most
likely a minor syntax thing). Thanks.

CONCEPT - I want the file ps2.asp to have a table that reads a text
file (ps2.txt) and uses the info in it as variables to display certain
files/info.
ps2.txt example -
grandtheftauto,used,19.95
truecrime,used,22.95

I need it to loop through each line, and display the information in
the table (as written in my code).


HERE IS THE CODE:

<%@language=PerlScript%>
<html>
<head>
<title>Ps2 Games - TEST PAGE</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<center><h1>TEST PAGE FOR gamedeals.ca</h1></center>
<p>
</p>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso = $Server->CreateObject("Scripting->FileSystemObject")
set greeting = $fso->GetFile(server->MapPath("ps2.txt"))
set ts = $greeting->OpenAsTextStream(ForReading, -2)

my $varText

Do while not ts.AtEndOfStream
$varText = ts->ReadLine
$varText = split($varText,",")
%>
<table>
<tr>
<td><IMG SRC="<%=$varText(0)%>.jpg"></td>
<td><embed src="<%=$varText(0)%>.html"></embed></td>
<td><%=$varText(1)%><br>$<%=$varText(2)%></td>
</tr>
</table>
<%
loop

%>
<p>
</p>
Here is the bottom of the page...
</body>
</html>


Can anyone help me?
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      07-14-2004
Brian wrote:

> Can anyone help me?


Simply put, you need to learn the Perl language. There's no "set" in Perl,
no "Const", statements end with a semicolon, and your "$"s appear to be
randomly placed.

Go to <http://learn.perl.org>, and start reading.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
Richard Morse
Guest
Posts: n/a
 
      07-14-2004
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) (Brian) wrote:

> <%@language=PerlScript%>
> <html>
> <head>
> <title>Ps2 Games - TEST PAGE</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
> <body>
> <center><h1>TEST PAGE FOR gamedeals.ca</h1></center>
> <p>
> </p>
> <%
> Const ForReading = 1, ForWriting = 2, ForAppending = 8
> set fso = $Server->CreateObject("Scripting->FileSystemObject")
> set greeting = $fso->GetFile(server->MapPath("ps2.txt"))
> set ts = $greeting->OpenAsTextStream(ForReading, -2)
>
> my $varText
>
> Do while not ts.AtEndOfStream
> $varText = ts->ReadLine
> $varText = split($varText,",")
> %>
> <table>
> <tr>
> <td><IMG SRC="<%=$varText(0)%>.jpg"></td>
> <td><embed src="<%=$varText(0)%>.html"></embed></td>
> <td><%=$varText(1)%><br>$<%=$varText(2)%></td>
> </tr>
> </table>
> <%
> loop
>
> %>
> <p>
> </p>
> Here is the bottom of the page...
> </body>
> </html>


I'm not sure how you think this looks at all like Perl. I haven't used
PerlScript, but I'm betting you need to start looking more at something
like:

<%@Language=PerlScript$>
<html>
<head>...</head>
<body>
<%
my $f = open(my $in, "<", $Server->MapPath("ps2.txt")) or die($!);
while(<$f>) {
my ($src, $line1, $line2) = split /,/;
%>
<table><tr>
<td><img src="<%=$src%>.jpg" alt="" /></td>
<td><embed src="<%=$src$>.html"></embed></td>
<td><%=$line1%><br><%=$line2%></td>
</tr></table>
<%
}
%>
more stuff
</body>
</html>

I'm not sure if the reading of files is done in this way -- I would
check out the documentation to be sure.

Be aware that case matters...

HTH,
Ricky
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      07-14-2004

"Brian" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hello all. I'm coding a site right now, but I don't know Perl or asp
> (other than what I've learned in the last few days). I had someone
> helping me write some ASP code, but it is in VBscript, unfortunately
> my server only accepts PerlScript. I've converted as much of it as I
> can, but it still doesn't work. It's a simple script, and I'm
> wondering if someone can look it over and tell me what's wrong (most
> likely a minor syntax thing). Thanks.
>
> CONCEPT - I want the file ps2.asp to have a table that reads a text
> file (ps2.txt) and uses the info in it as variables to display certain
> files/info.
> ps2.txt example -
> grandtheftauto,used,19.95
> truecrime,used,22.95
>
> I need it to loop through each line, and display the information in
> the table (as written in my code).
>
>
> HERE IS THE CODE:
>


<snip>

I don't have a server handy, but the following untested code should do what
you want:

<%@Language=PerlScript%>
<%

use strict;
use warnings;
use vars qw/$Request $Response $Session/;

open(my $txtfile, '<', 'ps2.txt') or die "Could not open ps2.txt: $!";

my $varText;

while (my $line = <$txtfile>) {

my @values = split(/,/, $varText);

$varText .= <<TABLE;
<table>
<tr>
<td><IMG SRC="$values[0].jpg"></td>
<td><embed src="$values[0].html"></embed></td>
<td>$values[1]<br>$values[2]</td>
</tr>
</table>
TABLE

}

%>

<html>
<head>
<title>Ps2 Games - TEST PAGE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center><h1>TEST PAGE FOR gamedeals.ca</h1></center>

<%= $varText %>

<p>Here is the bottom of the page...</p>
</body>
</html>


 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      07-14-2004

"Matt Garrish" <(E-Mail Removed)> wrote in message
news:sihJc.18987$(E-Mail Removed) ...
>
> "Brian" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > Hello all. I'm coding a site right now, but I don't know Perl or asp
> > (other than what I've learned in the last few days). I had someone
> > helping me write some ASP code, but it is in VBscript, unfortunately
> > my server only accepts PerlScript. I've converted as much of it as I
> > can, but it still doesn't work. It's a simple script, and I'm
> > wondering if someone can look it over and tell me what's wrong (most
> > likely a minor syntax thing). Thanks.
> >
> > CONCEPT - I want the file ps2.asp to have a table that reads a text
> > file (ps2.txt) and uses the info in it as variables to display certain
> > files/info.
> > ps2.txt example -
> > grandtheftauto,used,19.95
> > truecrime,used,22.95
> >
> > I need it to loop through each line, and display the information in
> > the table (as written in my code).
> >
> >
> > HERE IS THE CODE:
> >

>
> <snip>
>
> I don't have a server handy, but the following untested code should do

what
> you want:
>
> <%@Language=PerlScript%>
> <%
>
> use strict;
> use warnings;
> use vars qw/$Request $Response $Session/;
>
> open(my $txtfile, '<', 'ps2.txt') or die "Could not open ps2.txt: $!";
>
> my $varText;
>
> while (my $line = <$txtfile>) {
>
> my @values = split(/,/, $varText);
>


Oops, that should be:

my @values = split(/,/, $line);

Matt


 
Reply With Quote
 
ChrisO
Guest
Posts: n/a
 
      07-17-2004
Brian wrote:

> Hello all. I'm coding a site right now, but I don't know Perl or asp
> (other than what I've learned in the last few days). I had someone
> helping me write some ASP code, but it is in VBscript, unfortunately
> my server only accepts PerlScript.


I consider this highly unlikely under IIS that PerlScript is supported
but VBScript is not. In most cases, it's entirely the other way around.
The only way this could possibly be true is if someone (1) installed
the PerlScript engine then (2) removed the VBScript engine (by deleting
or renaming the VBScript DLL).

>I've converted as much of it as I
> can, but it still doesn't work. It's a simple script, and I'm
> wondering if someone can look it over and tell me what's wrong (most
> likely a minor syntax thing). Thanks.


[Snipped code]

Do yourself a few favors here:

(1) Learn Perl first if you are going to use PerlScript. You don't even
need to know VBScript to code in PerlScript using IIS/ASP. Just learn
Perl first. Knowing Perl puts you 95% of the way to using PerlScript as
an ASP engine.

(2) DON'T attempt to convert VBScript code to PerlScript. VBScript is
about as stupid and idiotic a language as I've ever seen. The
PerlScript engine absolutely blows VBScript out of the water in every
way; there is no comparision between the two. So DON'T try to convert
VBScript to PerlScript.

For instance, in VBScript to open a text file (as you are trying to do),
yes, you have to use something as incrediblely stupid as a
"FileSystemObject" to do it. It takes a ridiculous number of objects,
methods and lines of code to read a text file in VBScript. In
PerlScript, you access text files as you would in normal Perl. And
handling a text file is just ONE example of this sort of thing. (I
honestly think in Redmond, people sit around and try to figure out the
most complicated way to make something work. It's like adding numbers
using logrythms and exponents. That company is so clueless when it
comes to raw technology... It took someone from OUTSIDE to architect
something like .NET.)

(3) Once you've got #1 and #2 down, then realize that in PerlScript,
yes, there are a FEW anomalies that you have to make allowances for in
order to make things work in ASP. Namely, the use of the ASP objects:
Session ($Session), Request ($Request), Response ($Response),
Application ($Application), and the two other objects I can't remember
off the top of my head right now. For instance, you can't "print" in
PerlScript, you have to $Response->Write(). But other than those few
things, PerlScript under ASP is 95% identical to Perl. So don't try to
do VBScript -> PerlScript conversions.

And just for the sake of others who are reading this (I wouldn't attempt
this if you are already having the difficulties you are having):
PerlScript ASP coupled with HTML::Template is an absolutely fabulous and
powerful environment to do Web development in. .NET-like capabilities
can be realized with PerlScript and HTML::Template.

-ceo
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help...Do anyone know how to exit modelsim(vsim) by using perlscript?? tuspa Perl 0 07-20-2007 05:45 PM
Help...Do anyone know how to exit modelsim(vsim) by using perlscript?? tuspa VHDL 0 07-20-2007 05:44 PM
Using PerlScript In ASP KaXo Perl 2 03-03-2004 08:01 AM
Passing Variables from One Perlscript to Another Joe Perl 1 09-30-2003 11:03 PM
Access Right for Perlscript to Read Windows EventLog Remotely Joe Perl 1 09-29-2003 05:29 PM



Advertisments