Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

lib::abs(3pm) [debian man page]

lib::abs(3pm)						User Contributed Perl Documentation					     lib::abs(3pm)

NAME
lib::abs - "lib" that makes relative path absolute to caller. SYNOPSIS
Simple use like "use lib ...": use lib::abs qw(./mylibs1 ../mylibs2); use lib::abs 'mylibs'; Extended syntax (glob) use lib::abs 'modules/*/lib'; There are also may be used helper function from lib::abs (see example/ex4): use lib::abs; # ... my $path = lib::abs::path('../path/relative/to/me'); # returns absolute path DESCRIPTION
The main reason of this library is transformate relative paths to absolute at the "BEGIN" stage, and push transformed to @INC. Relative path basis is not the current working directory, but the location of file, where the statement is (caller file). When using common "lib", relative paths stays relative to curernt working directory, # For ex: # script: /opt/scripts/my.pl use lib::abs '../lib'; # We run `/opt/scripts/my.pl` having cwd /home/mons # The @INC will contain '/opt/lib'; # We run `./my.pl` having cwd /opt # The @INC will contain '/opt/lib'; # We run `../my.pl` having cwd /opt/lib # The @INC will contain '/opt/lib'; Also this module is useful when writing tests, when you want to load strictly the module from ../lib, respecting the test file. # t/00-test.t use lib::abs '../lib'; Also this is useful, when you running under "mod_perl", use something like "Apache::StatINC", and your application may change working directory. So in case of chdir "StatINC" fails to reload module if the @INC contain relative paths. RATIONALE
Q: We already have "FindBin" and "lib", why we need this module? A: There are several reasons: 1) "FindBin" could find path incorrectly under "mod_perl" 2) "FindBin" works relatively to executed binary instead of relatively to caller 3) Perl is linguistic language, and `use lib::abs "..."' semantically more clear and looks more beautiful than `use FindBin; use lib "$FindBin::Bin/../lib";' 4) "FindBin" b<will> work incorrectly, if will be called not from executed binary (see <http://github.com/Mons/lib-abs-vs-findbin> comparison for details) BUGS
None known COPYRIGHT &; LICENSE Copyright 2007-2010 Mons Anderson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Mons Anderson, "<mons@cpan.org>" CONTRIBUTORS
Oleg Kostyuk, "<cub@cpan.org>" perl v5.10.1 2010-11-16 lib::abs(3pm)

Check Out this Related Man Page

FindBin(3pm)						 Perl Programmers Reference Guide					      FindBin(3pm)

NAME
FindBin - Locate directory of original perl script SYNOPSIS
use FindBin; use lib "$FindBin::Bin/../lib"; or use FindBin qw($Bin); use lib "$Bin/../lib"; DESCRIPTION
Locates the full path to the script bin directory to allow the use of paths relative to the bin directory. This allows a user to setup a directory tree for some software with directories "<root>/bin" and "<root>/lib", and then the above example will allow the use of modules in the lib directory without knowing where the software tree is installed. If perl is invoked using the -e option or the perl script is read from "STDIN" then FindBin sets both $Bin and $RealBin to the current directory. EXPORTABLE VARIABLES
$Bin - path to bin directory from where script was invoked $Script - basename of script from which perl was invoked $RealBin - $Bin with all links resolved $RealScript - $Script with all links resolved KNOWN ISSUES
If there are two modules using "FindBin" from different directories under the same interpreter, this won't work. Since "FindBin" uses a "BEGIN" block, it'll be executed only once, and only the first caller will get it right. This is a problem under mod_perl and other persistent Perl environments, where you shouldn't use this module. Which also means that you should avoid using "FindBin" in modules that you plan to put on CPAN. To make sure that "FindBin" will work is to call the "again" function: use FindBin; FindBin::again(); # or FindBin->again; In former versions of FindBin there was no "again" function. The workaround was to force the "BEGIN" block to be executed again: delete $INC{'FindBin.pm'}; require FindBin; AUTHORS
FindBin is supported as part of the core perl distribution. Please send bug reports to <perlbug@perl.org> using the perlbug program included with perl. Graham Barr <gbarr@pobox.com> Nick Ing-Simmons <nik@tiuk.ti.com> COPYRIGHT
Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 FindBin(3pm)
Man Page