NAME

App::rlibperl - Execute perl prepending relative lib to @INC

VERSION

version 0.400

SYNOPSIS

Install this into a local::lib directory to simplify including the local::lib when calling perl:

# cron job:
* * * * * /project/dir/bin/rlibperl -MProject::App -e 'run()'

# program configuration file:
command = /home/username/perl5/bin/rlibperl -MSome::Mod -e 'do { something; }'

If you're lazy (like me) you can use it in the shebang line:

#!/home/username/perl5/bin/rlibperl

Then you don't need to add an explicit

use lib '/home/username/perl5/lib/perl5';

before any of your other code.

It also uses the environment to find perl similar to the common #!/usr/bin/env perl trick (using the common eval 'exec...'\n if 0 trick).

DESCRIPTION

The rlibperl script simplifies the inclusion of relative library directories with perl.

Upon execution the script will look for lib directories relative to the location of the script then re-invoke perl with all supplied command line arguments and any found lib directories added to @INC.

The script was designed to be installed via local::lib (though local::lib is not required). Once installed, executing the script is just like executing perl except that it adds the local lib directories to @INC for you.

It also adds the directory of the script to $PATH like local::lib does which enables system/qx/exec/etc. to find executables in that directory.

So this:

$HOME/perl5/bin/rlibperl -MSome::Module -e 'do_something'

is roughly the equivalent of:

PATH=$HOME/perl5/bin:$PATH perl \
   -I$HOME/perl5/lib/perl5 -MSome::Module -e 'do_something'

If that isn't useful enough (it probably isn't) check out App::rbinperl which automatically adds -S which makes it just as easy to execute another script in that bin directory.

DIRECTORY STRUCTURES

rlibperl will look for the following directory structures relative to the directory in which it is located:

If the script is located in a directory named bin (or script or scripts) it assumes a structure similar to local::lib and will first look for ../lib/perl5:

${root}/bin/rlibperl
${root}/lib/perl5

If not found it will check for ./lib.

${root}/rlibperl
${root}/lib

(If rlibperl is not located in a directory matching /bin|scripts?/ the order will be reversed: it will look for ./lib first.)

Lastly it will check for simply ../lib.

${root}/bin/rlibperl
${root}/lib

If you have another directory structure you think should be supported please send suggestions!

SEE ALSO

  • App::rbinperl - included

  • local::lib - The module that makes this one useful.

  • ylib (perl -Mylib) - Configurable additional lib directories

  • Devel::Local - An alternative to the above modules

  • rlib - This module is not related to or dependent on rlib but it serves a similar purpose in a different situation.

SUPPORT

Perldoc

You can find documentation for this module with the perldoc command.

perldoc App::rlibperl

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-app-rlibperl at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-rlibperl. You will be automatically notified of any progress on the request by the system.

Source Code

https://github.com/rwstauner/App-rlibperl

git clone https://github.com/rwstauner/App-rlibperl.git

AUTHOR

Randy Stauner <rwstauner@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Randy Stauner.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.