- CLASS METHODS
- SEE ALSO
File::AddInc - FindBin(+ use lib) alike for *.pm modulino (instead of *.pl)
In file MyApp/Deep/Runnable/Module.pm:
#!/usr/bin/env perl package MyApp::Deep::Runnable::Module; # use MyApp::Util; # This may fail because @INC can be wrong in many ways. # So, use this to modify @INC. use File::AddInc; # Then perl can find MyApp/Util.pm correctly. use MyApp::Util; ...
Suppose you have a module like above and want to make it runnable and symlink it from your ~/bin (Yes, I'm sane;-). In the module, you want to use some other module (MyApp/Util.pm) in the same library tree. File::AddInc will locate your lib directory and modify @INC for you.
File::AddInc is a
@INC tuner for Modulino.
Conceptually, this module locates root of lib directory through following steps.
Resolve symbolic links.
__PACKAGE__part from it.
Then adds it to
$PACKNAME portion from
$FILEPATH. When arguments are omitted, results from caller() is used.
my $libdir = File::AddInc->libdir('MyApp::Foobar', "/somewhere/lib/MyApp/Foobar.pm"); # $libdir == "/somewhere/lib" my $libdir = File::AddInc->libdir(caller); my $libdir = File::AddInc->libdir;
This module does *NOT* rely on MOP4Import::Declare but designed to work well with it. Actually, this module provides
declare_file_inc method. So, you can inherit 'File::AddInc' to reuse this pragma.
package MyExporter; use MOP4Import::Declare -as_base, [parent => 'File::AddInc'];
Then you can use
-file_inc pragma like following:
use MyExporter -file_inc;
Since this module compares
__PACKAGE__ in case sensitive manner, it may not work well with modules which relies case insensitive filesystems.
Copyright (C) Kobayasi, Hiroaki.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Kobayasi, Hiroaki <firstname.lastname@example.org>