user2713461
user2713461

Reputation: 397

How to check whether Perl DBI module present in my system?

I'm using Perl in XAMPP for server-side scripting.
I want to access Database from Perl. I'm using use DBI;.
How to check whether Perl DBI is present in my system? I'm getting Server-Error. Error 500.
I'm using Tomcat server.

Upvotes: 2

Views: 9660

Answers (4)

slayedbylucifer
slayedbylucifer

Reputation: 23532

All above answers should answer your question. I am just adding my way of doing it.

$ perl -e 'use DBI'
$ 

No output above. It means the module is installed. If the module is not installed, then:

$ perl -e 'use dbi'
Can't locate dbi.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

So, in this case, you get the Can't locate .... error.

Upvotes: 2

ysth
ysth

Reputation: 98528

Note that DBI doesn't access databases; it provides an interface to various database driver modules that actually access databases. For instance, you would use DBI together with DBD::mysql to access mysql databases.

A 500 error indicates that your script had a fatal error; a missing module is one of many possible such errors. To do any kind of reasonable development, you will need to be able to see these actual errors, which will be in an error log somewhere. In a pinch, use CGI::Carp 'fatalsToBrowser'; at the top of your script` can be a substitute during development (if you have CGI::Carp).

Upvotes: 1

Chankey Pathak
Chankey Pathak

Reputation: 21676

Another approach to check if a module is installed or not

perldoc -l DBI

Upvotes: 0

Ron Bergin
Ron Bergin

Reputation: 1068

Another command line option to check if a module is installed would be:

perl -MDBI -e 1

No output means that it's installed. If you receive any output, then you know it not installed, or maybe it wasn't installed correctly and should be reinstalled.

Upvotes: 11

Related Questions