The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Please can someone replicate this ASP script using PERL
Discuss Please can someone replicate this ASP script using PERL in the Perl Programming forum on Dev Shed. Please can someone replicate this ASP script using PERL Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 16th, 2000, 04:12 AM
|
|
Junior Member
|
|
Join Date: Aug 2000
Location: Exeter, Devon, UK
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi everyone. I'm new to this forum and very new to PERL - in fact I have no knowledge of it at all so please excuse my ignorance.
I've written a script for a client in ASP that connects to a database and pulls out a few values depending on a number entered in a HTML form element. It's dead straight forward, just about half a dozen lines of code.
I've since found out that the server this script was to reside on doesn't support ASP, only CGI/PERL and I'm stuck. If anyone thinks they could help replicate my script in PERL I'd be very grateful. As yet I don't know whether I'm going to be paid for this job but if I am, I'll go 50/50 with you.
What I'd basically like to know is can PERL be used to connect to a MS Access Database on an Apache Server? If so, is it easy and can it do something like the ASP script below?
Please email me if you want the full source code and an example Access database.
Thanks in advance.
Head8k
----------
<%@ Language = VBscript %>
<%
Dim passedVar, showInfo, infoSQL, objConn
'This variable is comes from the referring page
passedVar=Request.Form("ID")
'use the Primary key for the query.
infoSQL="SELECT FinTime, Forename, Surname FROM runners WHERE StartNo='" & passedVar & "'"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ("driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("mydatabase.mdb"))
set showInfo=objConn.execute(infoSQL)
%>
<html>
<head>
<title></title>
</head>
<body onLoad="self.focus()">
<p>This page will contain other page elements, I'll format it later.
Finishing Time:
<%= showInfo(0) %><br>
Forename:
<%= showInfo(1) %><br>
Surname:
<%= showInfo(2) %><br>
</body>
</html>
----------
|

August 16th, 2000, 08:23 AM
|
|
Contributing User
|
|
Join Date: Aug 2000
Posts: 82
Time spent in forums: 1 h 23 m 46 sec
Reputation Power: 13
|
|
|
Well, I dont know if you would really want to use access with apache. Does the situation require it? Is it a large (greater than 3 tables, more than 1000 records) database? If not, there are workarounds. Send me some mail at josh_schoof@yahoo.com.
The perl would look something like this:
#!/perl
use CGI;
use YourDBPackage;
$query = new CGI;
$app = new YourDBPackage;
my $passedVar;
my $showInfo;
my $infoSQL;
my $objConn;
$passedVar = $query->param(ID);
$infoSQL = "SELECT FinTime, Forename, Surname FROM runners WHERE StartNo='$passedVar'";
$objConn = $app->Recordset($infoSQL);
@showInfo = $recset->fetchrow;
print <<HTML;
<html>
<head>
<title></title>
</head>
<body onLoad="self.focus()">
This page will contain other page elements, I'll format it later.
Finishing Time:
$showInfo[0]
Forename:
$showInfo[1]
Surname:
$showInfo[2]
</body>
</html>
And so forth. The only consideration is the "YourDBPackage" bit. I usually make
up a .PM file with some handy DB functions in it, like the Recordset one seen
above. That function looks like:
sub Recordset {
my ($self, $sqlStr) = @_;
my $recset = $db->prepare($sqlStr);
if ($recset) {
$recset->execute;
return $recset;
}
else {Error("",$DBI::errstr)}
}
Just set up your DB connection as "$db" and let er rip.
Josh
[This message has been edited by JSchoof (edited August 16, 2000).]
[This message has been edited by JSchoof (edited August 16, 2000).]
|

August 16th, 2000, 10:42 AM
|
|
Contributing User
|
|
Join Date: Aug 2000
Location: Indiana
Posts: 614
  
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 14
|
|
|
Yes, you should use something like mysql database for a *nix server.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|