perl packaging dbd mysql module in script

510 views Asked by At

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. 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? I tried the same way by copying the .pm files and it either gives me

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
1

There are 1 answers

0
Josh Y. On BEST ANSWER

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. 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.