/ domm

I hack Perl for fun and profit.

Follow me on twitter!
Atom Icom ... on Atom!
<<<<<<<<<<
25.12.2014: Making presents with Perl
07.12.2014: First release of lib::projectroot

I've just uploaded lib::projectroot 1.000 to CPAN. (formerly known as File::LoadLocalLib)

lib::projectroot makes it easier to load all the project-specific, non-CPAN code ("DarkPAN") in your project's scripts.

For an example, assume you have a script somewhere deep down in your project tree (for example, bin/admin/fixups/realign_flux_compensator.pl). Add this to the top of your script:

use lib::projectroot qw(lib local::lib=local);
lib::projectroot->load_extra(Your-OtherModule Dark-PAN);

lib::projectroot will find the root of your project by walking up the from the directory the script is located, until it finds a directory containing the dirs lib and local. lib will be added to @INC, and local will be loaded via local::lib.

load_extra will then walk up another directory (i.e. to the one containing your project) and look for dirs there named Your-OtherModule and Dark-PAN. If those dirs themselves contain a dir called lib, those lib-dirs will be also added to @INC.
This makes sense if you have a lot of local code packed into CPAN-like dists but not published on CPAN or managed via thinks like CPAN::Mini::Inject or Pinto

Of course you will need to install lib::projectroot into your proper Perl (System Perl or the perlbrew). You cannot install it via local::lib, if you want to use the local::lib features...

Here's my first draft as published on prepan.org, and the github repo

Thanks to eserte, Smylers & abraxxa for providing feedback at
prepan; and to koki,
farhad and Jozef for providing face-to-face feedback.

Comments (via disqus)

30.11.2014: Please review File::LoadLocalLib
26.10.2014: Videos of Austrian Perl Workshop 2014
05.09.2014: Going to Silicon Valley
29.08.2014: Things I learned at YAPC::Europe 2014 in Sofia
10.07.2014: Where will YAPC::Europe 2015 take place?
04.06.2014: Announcing the Austrian Perl Workshop 2014
27.05.2014: Modification of a read-only value attempted
25.05.2014: App::TimeTracker::Command::Trello
>>>>>>>>>>