473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Perl embed in C++

Hi,
I am executing perl script through my C++ code with the help of "perlembed" and it is working fine for normal perl systax and perl functions.But when I try to access database from the perl script which I am passing to my C++ program it gives me following error :

"Can't locate object method "se" via package "DBI" (perhaps you forgot to load "DBI"?)"


I have DBI.pm in my ld_library_path.

Please suggest what is missing or doing wrong.

Thanks in Advance
Dec 11 '07 #1
7 2788
sicarie
4,677 Expert Mod 4TB
Can you run your PERL script on it's own without errors?
Dec 11 '07 #2
yes I can run that script directly through perl interpreter.
Dec 11 '07 #3
sicarie
4,677 Expert Mod 4TB
Does your error contain a line number?
Dec 11 '07 #4
Here is my script along with the error message I am getting:

use DBI;

$user = "emulator";
$password = "";
$dbname = "nocc532";

$dbh = DBI->connect("dbi:Pg:dbname=$dbname", $user, $password);
$sth = $dbh->prepare("select * from dictionary");
$sth->execute;

while ( @row = $sth->fetchrow_array ) {
print "@row\n";
}

$dbh->disconnect;



Error Message:

Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at - line 7.
Dec 11 '07 #5
sicarie
4,677 Expert Mod 4TB
So can we see lines 6-9 of your C++ code?
Dec 11 '07 #6
Here is my C++ code

#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}



but what I think the line number in error message is the script line number which I am giving to my C code.


Thanks
Dec 12 '07 #7
Hi,
Could any one please help me,bcz this is realy blocking for me.


Thanks,
Dec 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the...
42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
0
by: Chris | last post by:
Hi I am researching a new commercial project, and would like to incorporate scripting, I use perl a lot and it is my language of choice for a script (see next post) BUT I seem to be having...
3
by: David F. Skoll | last post by:
Hi, I'm tearing my hair out on this one. I'm trying to embed a Perl interpreter into a C program. I need to be able to create and destroy the interpreter periodically, but will never actually...
1
by: Kris De Schutter | last post by:
Hello everyone, I'm looking for a document which shows me how to set up a C application with an embedded Perl engine in such a way that the Perl engine can call back to the parent application. ...
7
by: Ajar | last post by:
I want to write a program which will automatically login to my ISPs website, retrieve data and do some processing. Can this be done? Can you point me to any example python programs which do similar...
2
by: Kai Thorsrud | last post by:
Hi I'm currently into converting a perl linux app into a .Net windows service. The application monitors our syslog log files to capture i.p adress changes on some of our routers having dynamic...
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
4
by: =?ISO-8859-7?B?1/H189zt6Ocgwfrt4eve?= | last post by:
How can I convert a perl script to Python? Thank you!
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.