http://www.perlmonks.org?node_id=654634


in reply to How to include CPAN packages in distribution package

Wow, I'm just about to submit the same question when I see this post. Let me add a little detail to my version of the same question.

I'm trying to add a custom tool that needs a DBI/mysql combination, the perl installation doesn't have DBI/mysql. I'd like the user to be able to use my package (say via gunzip/tar) without installing any perl modules. What's the best way to package it?

  • Comment on Re: How to include CPAN packages in distribution package

Replies are listed 'Best First'.
Re^2: How to include CPAN packages in distribution package
by tsee (Curate) on Dec 03, 2007 at 20:52 UTC
Re^2: How to include CPAN packages in distribution package
by halley (Prior) on Dec 03, 2007 at 20:22 UTC
    If you intend to embed modules into your application, your application can use lib to find them in your own private library directory (a part of your application). After use lib, perl will see the updated value of @INC in its search for subsequent use statements.
    BEGIN { $INSTALLDIR = my_fun_to_find_my_own_install_dir() } use lib "$INSTALLDIR/privatelib"; use Acme::SuperModule qw(whatever);

    The upside is that you have some control over the versions that folks will use, and thus you can more easily guarantee proper execution. The downside to this approach is that the writer of that embedded module (e.g., Acme::SuperModule) might fix a critical bug, and your customers won't get the benefits until you ship them a new version.

    --
    [ e d @ h a l l e y . c c ]

Re^2: How to include CPAN packages in distribution package
by johnnywang (Priest) on Dec 03, 2007 at 21:34 UTC
    Thanks, I knew about "use lib" for my own lib paths, just never tried to have a CPAN module like DBI in my own path.

    I just did a manual make of DBI from source, all the files are in the usual blib directory, I'm thinking that if I put everything of blib (except the docs) as part of my distribution (keeping the same structure like: lib/auto, lib/Bundle, lib/DBD, etc.) it should all work. I guess I'll just go ahead and do that, and report back.

    Update Yes, it's as simple as that, I took the blib/lib directory, and moved it somewhere, and just do "use lib" to point there, all worked fine.