Randy Stauner > App-rlibperl > App::rlibperl

Download:
App-rlibperl-0.700.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.700   Source  

NAME ^

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

VERSION ^

version 0.700

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.

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!

BUGS AND LIMITATIONS ^

The initial use-case for rlibperl was installing via local::lib (or without it using something like cpanm --local-lib /other/dir) and calling like so:

  $ /path/to/local-lib/rlibperl -perl-args

(It may also be useful in a per-project setting, though it's likely easier to make custom scripts and/or use the unrelated rlib.)

The following limitations exist when used in other situations, however they are considered bugs and may be "fixed" at some point (so their functionality should not be relied upon):

If you think other functionality would be useful please submit examples, rationale, or patches.

SEE ALSO ^

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.

syntax highlighting: