LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2005, 11:08 AM   #1
ankscorek
Member
 
Registered: Mar 2003
Distribution: Slackware10.2,SUSE,FC,RHL,Vector Linux,WHAX,PHLAK,bt4,ubuntu,debian,aptosid,backtrack,blackbuntu
Posts: 529

Rep: Reputation: 31
Exclamation starting on perl


helloo i have created a backend for a database in mySQl
i want to make a frontend using perl

how do i go abt it
i am an absolute starter at this so it will be appreciated if someone can guide me to an ebook regarding building a frontened using perl
 
Old 03-28-2005, 11:15 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hi there

u can have a look at all the man pages of perl using

apropos perl

also have a look athe code of webmin that will help

regards
 
Old 03-28-2005, 02:44 PM   #3
TheLinuxDuck
Member
 
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
In order to connect with a mySQL DB in perl, you're going to need to install the DBI/DBD modules.. they may come with newer installs of perl, but I don't know for certain. The INSTALL and README files in the module archives will tell you exactly what components you need to install..

The DBI package:
http://cpan.uwinnipeg.ca/dist/DBI

The DBD-mysql driver package:
http://cpan.uwinnipeg.ca/dist/DBD-mysql

I feel like there's one more thing that needs to be installed, but it's escaping me at the moment.. the README/INSTALL's for the DBI and DBD-mysql will tell you everything that you'll need installed.

As for perl, making a connection is pretty easy:
Code:
use DBI;

my($sqlDBName) = 'geography';
my($sqlDBUser) = 'Steve';
my($sqlDBpass) = 'getstuffed';

my($db) = DBI->connect("DBI:mysql:$sqlDBName", $sqlDBUser, $sqlDBPass) or
  die "Error connecting to $sqlDBName: ", $DBI::errstr, "\n";
Then create your query string, prepare it, then execute it:
Code:
my($query) = "SELECT * from country";
my($call) = $db->prepare($query);
if(!defined($call)) {
  die "Prepare failed on query '$query'.\n",
      "Reason: ", $db->errstr, "\n";
}
else {
  if(!$call->execute()) {
  die "Execute failed on query '$query'.\n",
      "Reason: ", $db->errstr, "\n";
  }
}
Then, it's a matter of looping through the results, depending on whether you want to use an array or a hash.

You can take a look at here at the manpage of DBD-mysql for more examples and information about the connection.

Another question is, when you say beginner, does that mean in perl, with CGI's or what?
 
Old 03-30-2005, 09:48 PM   #4
ankscorek
Member
 
Registered: Mar 2003
Distribution: Slackware10.2,SUSE,FC,RHL,Vector Linux,WHAX,PHLAK,bt4,ubuntu,debian,aptosid,backtrack,blackbuntu
Posts: 529

Original Poster
Rep: Reputation: 31
well thanx for all the help ...i am an absolute newbie at perl..like to start off from absolute basics
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting perl alienDog Programming 1 11-02-2005 11:01 AM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
Yum error: .conflict between perl and perl-NDBM_File zepplin611 Red Hat 3 10-20-2004 10:22 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration