Downloading and installing
The Active version
of Perl is well documented and
build as of this writing is available
is the simplest process of all and any
user should be able to do that quite
Enabling CGI access
No ..No.. i am not explaining
that. This is a slightly tricky
issue and explaining
that would extend the length and
to divert from the topic. This
make the reader aware that
it is one
to make an interactive communication
possible with the web server,
which is the basis for all
programming over the web. Complete
available, which comes along with the
Perl download and
it could be referred for enabling CGI
access with various Web Servers.
also help you
access the reference available from the
You can in addition use this link,
case you are using Microsoft
Internet Information Server
or Microsoft Personal Web
The Database connectivity
To establish database
connectivity you need to have
an ODBC compliant
database, and a Perl extension
access to the ODBC
(API) . Win32::ODBC is a Perl 5
by Dave Roth and is available from
. The installation instructions alone
repeated below from
page to Win32::ODBC
details such as the
etc., can be had by
clicking the link.
1. Copy the ODBC.PM file into the
2. Copy the
ODBC10x.PLL file into
directory. This is
(for versions of Perl 105 or before)
(for versions of Perl 106 or later),
correct file to ODBC.PLL (run "perl -v" to
check which version
of perl you have).
After successfully installing
Win32::ODBC you need to
create a System DSN.
Follow these steps carefully to
Creating a System DSN
1. Double-click the MyComputer Icon
and then open the
on your system.
2. Locate the ODBC Manger icon and
double-click on it.
The icon looks
3. Click the System DSN
tab and click Add. You will
be prompted to
select the ODBC driver, that you will
be using, from
the list of available drivers. If your
database is MS-Access
then choose the Microsoft
or choose the suitable driver
your database. This is followed by a dialog
box asking you
to enter the DataSource Name (DSN).
Type in any applicable
name. This is the name you will
in your programs to talk with your database.
This should be
unique. Then select the database to
4. If you require
you can also give a username and
password to connect
to the Datasource by choosing the
5. This completes the successful
creation of a System DSN.
Now moving on to some real programming.
I'll explain an example
code that should be enough to keep
you get going.
Consider a situation where you would
like to query a database
for the Author's name and
price of the book titled "CGI Programming
1. use Win32::ODBC;
2. $db=new WIN32::ODBC('simple');
3. $varname="CGI Programming with
4. $db->Sql("select aname,price
from mytable where
7. print "The Book titled
$varname is written by $Author
and costs $cost";
Line 1: Instruction
to the Perl Interpreter to include the package
Line 2: Creates a database
handle to the Datasource 'simple'.
Line 3: Assigns the
title of the book to the variable '$varname'.
Line 4: Passes a SQL
Query to the table 'mytable' through the
Line 5: Fetches the
First row of record that matches the Query.
Line 6: Assigns the
value of the fields 'aname' (Author name)
and 'price' to the variables $Author and $cost respectively.
Line 7: Prints the Result
Hope that was easy enough.
Let us proceed to see , how the same is implemented under the unix platform.