简体   繁体   English

如何检查系统中是否存在Perl DBI模块?

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

I'm using Perl in XAMPP for server-side scripting. 我在XAMPP中使用Perl进行服务器端脚本编写。
I want to access Database from Perl. 我想从Perl访问数据库。 I'm using use DBI; 我正在使用use DBI; .
How to check whether Perl DBI is present in my system? 如何检查我的系统中是否存在Perl DBI? I'm getting Server-Error. 我收到服务器错误。 Error 500 . Error 500
I'm using Tomcat server. 我正在使用Tomcat服务器。

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. 如果收到任何输出,则说明它未安装,或者可能未正确安装,应重新安装。

Note that DBI doesn't access databases; 请注意,DBI不会访问数据库。 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. 例如,您可以将DBI与DBD :: mysql一起使用来访问mysql数据库。

A 500 error indicates that your script had a fatal error; 错误500表示您的脚本有致命错误; 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'; 紧要关头, use CGI::Carp 'fatalsToBrowser'; at the top of your script` can be a substitute during development (if you have CGI::Carp). 在脚本的顶部可以在开发过程中替代脚本(如果您具有CGI :: Carp)。

检查模块是否已安装的另一种方法

perldoc -l DBI

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. 因此,在这种情况下,您会收到“ Can't locate ....错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM