简体   繁体   English

Perl在脚本中打包dbd mysql模块

[英]perl packaging dbd mysql module in script

I have a script and keep all external modules local so I can then package my entire script in a zip and have it work on all machines without having to install all the modules on different machines. 我有一个脚本,并将所有外部模块都保留在本地,因此我可以将整个脚本打包为zip格式,并使其在所有计算机上均可运行,而不必在不同计算机上安装所有模块。 I do: 我做:

use lib "$Bin/cpan"; 

I am trying to initiate a connection to a mysql database so I need to install DBD, DBI and mysql locally how can I do this? 我正在尝试启动与mysql数据库的连接,因此我需要在本地安装DBD,DBI和mysql怎么办? I tried the same way by copying the .pm files and it either gives me 我通过复制.pm文件尝试了相同的方法,它要么给了我

DBD::mysql initialisation failed: Can't locate object method "driver" via package "DBD::mysql" at C:/Perl/lib/DBI.pm line 815.

or 要么

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC

Simply transferring archives will probably not work, especially if you're transferring across operating systems or architectures (aside from simply missing files). 仅传输档案可能无法正常工作,尤其是在跨操作系统或体系结构进行传输时(除了丢失文件之外)。 I recommend using Carton to automate dependency management. 我建议使用Carton自动执行依赖关系管理。 Under the hood it uses local::lib (a brilliant module for dev and deployment in its own right) and cpanm to get the work done. 它在后台使用了local :: lib (一个出色的模块,可以独立开发和部署)和cpanm来完成工作。

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

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