Debian Codegraph @

README

raw
1 NAME
2 lib::abs - "lib" that makes relative path absolute to caller.
3
4 SYNOPSIS
5 Simple use like "use lib ...":
6
7 use lib::abs qw(./mylibs1 ../mylibs2);
8 use lib::abs 'mylibs';
9
10 # if your path may not exists and it is ok, then:
11 use lib::abs -soft => qw(./mylibs1 ../mylibs2);
12
13 Extended syntax (glob)
14
15 use lib::abs 'modules/*/lib';
16
17 There are also may be used helper function from lib::abs (see
18 example/ex4):
19
20 use lib::abs;
21 # ...
22 my $path = lib::abs::path('../path/relative/to/me'); # returns absolute path
23
24 DESCRIPTION
25 The main reason of this library is transformate relative paths to
26 absolute at the "BEGIN" stage, and push transformed to @INC. Relative
27 path basis is not the current working directory, but the location of
28 file, where the statement is (caller file). When using common "lib",
29 relative paths stays relative to curernt working directory,
30
31 # For ex:
32 # script: /opt/scripts/my.pl
33 use lib::abs '../lib';
34
35 # We run `/opt/scripts/my.pl` having cwd /home/mons
36 # The @INC will contain '/opt/lib';
37
38 # We run `./my.pl` having cwd /opt
39 # The @INC will contain '/opt/lib';
40
41 # We run `../my.pl` having cwd /opt/lib
42 # The @INC will contain '/opt/lib';
43
44 Also this module is useful when writing tests, when you want to load
45 strictly the module from ../lib, respecting the test file.
46
47 # t/00-test.t
48 use lib::abs '../lib';
49
50 Also this is useful, when you running under "mod_perl", use something
51 like "Apache::StatINC", and your application may change working
52 directory. So in case of chdir "StatINC" fails to reload module if the
53 @INC contain relative paths.
54
55 RATIONALE
56 Q: We already have "FindBin" and "lib", why we need this module?
57
58 A: There are several reasons:
59
60 1) "FindBin" could find path incorrectly under "mod_perl"
61 2) "FindBin" works relatively to executed binary instead of relatively
62 to caller
63 3) Perl is linguistic language, and `use lib::abs "..."' semantically
64 more clear and looks more beautiful than `use FindBin; use lib
65 "$FindBin::Bin/../lib";'
66 4) "FindBin" b<will> work incorrectly, if will be called not from
67 executed binary (see <http://github.com/Mons/lib-abs-vs-findbin>
68 comparison for details)
69
70 BUGS
71 None known
72
73 COPYRIGHT AND LICENSE
74 This software is copyright (c) 2007-2020 by Mons Anderson.
75
76 This is free software; you can redistribute it and/or modify it under
77 the same terms as the Perl 5 programming language system itself.
78
79 AUTHOR
80 Mons Anderson, "<[email protected]>"
81
82 CONTRIBUTORS
83 Oleg Kostyuk, "<[email protected]>"
84