[Chicago-talk] Portable Script and library

Steven Lembark lembark at wrkhors.com
Wed Dec 16 13:27:48 PST 2009

On Wed, 16 Dec 2009 14:44:08 -0600
Jay Strauss <me at heyjay.com> wrote:

> Hi,
> I need to build a script, to be able to bring with me from customer to
> customer site.  I can count on running upon a recent version of Perl
> (version will change from customer to customer).  I can not install new CPAN
> modules at their site.  (generally I'm on a heavily firewalled production
> box with no external http/ftp/ip access).   I will be running upon M$
> primarily.
> While at the customer I'll need to be able to make changes to the script as
> needed (and as I find needed new features or bugs).
> I have need for some modules on CPAN like date

You can run the thing with 

    /path/to/perl your-program

which avoids issues in #! paths (no guarantee they will
have Perl in the same place you do.

At that point you can create a local directory with:


directories in it. Put anything you need to take with
you -- including your own modules -- under ./lib. At
that point you can start your code with:

    use 5.008;
    use strict;
    use FindBin qw( $Bin );
    use lib "$Bin/../lib';

to include the local library directory:

    cd /blah/blah;
    /path/to/perl  ./bin/frobnicate 'whatever';

will set $Bin to "/blah/blah/bin" and leave you
using "/blah/blah/bin/../lib" for your modules.

Anything you need to take with you can be in 
the lib directory.

Add the same thing to your ./t files and you can
sanity check the thing with "prove" before trying
to run the remaining code.

Steven Lembark                                            85-09 90th St.
Workhorse Computing                                 Woodhaven, NY, 11421
lembark at wrkhors.com                                      +1 888 359 3508

More information about the Chicago-talk mailing list