.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Find::Lib 3pm" .TH Find::Lib 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Find::Lib \- Helper to smartly find libs to use in the filesystem tree .SH "VERSION" .IX Header "VERSION" Version 1.01 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #!/usr/bin/perl \-w; \& use strict; \& \& ## simple usage \& use Find::Lib \*(Aq../mylib\*(Aq; \& \& ## more libraries \& use Find::Lib \*(Aq../mylib\*(Aq, \*(Aqlocal\-lib\*(Aq; \& \& ## More verbose and backward compatible with Find::Lib < 1.0 \& use Find::Lib libs => [ \*(Aqlib\*(Aq, \*(Aq../lib\*(Aq, \*(Aqdevlib\*(Aq ]; \& \& ## resolve some path with minimum typing \& $dir = Find::Lib\->catdir("..", "data"); \& $path = Find::Lib\->catfile("..", "data", "test.yaml"); \& \& $base = Find::Lib\->base; \& # or \& $base = Find::Lib::Base; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The purpose of this module is to replace .PP .Vb 2 \& use FindBin; \& use lib "$FindBin::Bin/../bootstrap/lib"; .Ve .PP with something shorter. This is specially useful if your project has a lot of scripts (For instance tests scripts). .PP .Vb 1 \& use Find::Lib \*(Aq../bootstrap/lib\*(Aq; .Ve .PP The important differences between FindBin and Find::Lib are: .IP "\(bu" 4 symlinks and '..' .Sp If you have symlinks in your path it respects them, so basically you can forget you have symlinks, because Find::Lib will do the natural thing (\s-1NOT\s0 ignore them), and resolve '..' correctly. FindBin breaks if you do: .Sp .Vb 1 \& use lib "$Bin/../lib"; .Ve .Sp and you currently are in a symlinked directory, because \f(CW$Bin\fR resolved to the filesystem path (without the symlink) and not the shell path. .IP "\(bu" 4 convenience .Sp it's faster too type, and more intuitive (Exporting \f(CW$Bin\fR always felt weird to me). .SH "DISCUSSION" .IX Header "DISCUSSION" .SS "Installation and availability of this module" .IX Subsection "Installation and availability of this module" The usefulness of this module is seriously reduced if Find::Lib is not already in your \f(CW@INC\fR / \f(CW$ENV\fR{\s-1PERL5LIB\s0} \*(-- Chicken and egg problem. This is the big disavantage of FindBin over Find::Lib: FindBin is distributed with Perl. To mitigate that, you need to be sure of global availability of the module in the system (You could install it via your favorite package managment system for instance). .ie n .SS "modification of $0 and chdir (\s-1BEGIN\s0 blocks, other 'use')" .el .SS "modification of \f(CW$0\fP and chdir (\s-1BEGIN\s0 blocks, other 'use')" .IX Subsection "modification of $0 and chdir (BEGIN blocks, other 'use')" As soon as Find::Lib is compiled it saves the location of the script and the initial cwd (current working directory), which are the two pieces of information the module relies on to interpret the relative path given by the calling program. .PP If one of cwd, \f(CW$ENV\fR{\s-1PWD\s0} or \f(CW$0\fR is changed before Find::Lib has a chance to do its job, then Find::Lib will most probably die, saying \*(L"The script cannot be found\*(R". I don't know a workaround that. So be sure to load Find::Lib as soon as possible in your script to minimize problems (you are in control!). .PP (some programs alter \f(CW$0\fR to customize the display line of the process in the system process-list (\f(CW\*(C`ps\*(C'\fR on unix). .PP (Note, see perlvar for explanation of \f(CW$0\fR) .SH "USAGE" .IX Header "USAGE" .SS "import" .IX Subsection "import" All the work is done in import. So you need to \f(CW\*(Aquse Find::Lib\*(Aq\fR and pass a list of paths to add to \f(CW@INC\fR. See \*(L"\s-1BACKWARD COMPATIBILITY\*(R"\s0 section for more retails on this topic. .PP The paths given are (should) be relative to the location of the current script. The paths won't be added unless the path actually exists on disk .SS "base" .IX Subsection "base" Returns the detected base (the directory where the script lives in). It's a string, and is the same as \f(CW$Find::Lib::Base\fR. .SS "catfile" .IX Subsection "catfile" A shorcut to File::Spec::catfile using \fBFind::Lib\fR's base. .SS "catdir" .IX Subsection "catdir" A shorcut to File::Spec::catdir using \fBFind::Lib\fR's base. .SH "BACKWARD COMPATIBILITY" .IX Header "BACKWARD COMPATIBILITY" in versions <1.0 of Find::Lib, the import arguments allowed you to specify a Bootstrap package. This option is now \fBremoved\fR breaking backward compatibility. I'm sorry about that, but that was a dumb idea of mine to save more typing. But it saves, like, 3 characters at the expense of readability. So, I'm sure I didn't break anybody, because probabaly no one was relying on a stupid behaviour. .PP However, the multiple libs argument passing is kept intact: you can still use: .PP .Vb 1 \& use Find::Lib libs => [ \*(Aqa\*(Aq, \*(Aqb\*(Aq, \*(Aqc\*(Aq ]; .Ve .PP where \f(CW\*(C`libs\*(C'\fR is a reference to a list of path to add to \f(CW@INC\fR. .PP The short forms implies that the first argument passed to import is not \f(CW\*(C`libs\*(C'\fR or \f(CW\*(C`pkgs\*(C'\fR. An example of usage is given in the \s-1SYNOPSIS\s0 section. .SH "SEE ALSO" .IX Header "SEE ALSO" FindBin, FindBin::libs, lib, rlib, local::lib .SH "AUTHOR" .IX Header "AUTHOR" Yann Kerherve, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-find\-lib at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "ACKNOWLEDGEMENT" .IX Header "ACKNOWLEDGEMENT" Six Apart hackers nourrished the discussion that led to this module creation. .PP Jonathan Steinert (hachi) for doing all the conception of 0.03 shell expansion mode with me. .SH "SUPPORT & CRITICS" .IX Header "SUPPORT & CRITICS" I welcome feedback about this module, don't hesitate to contact me regarding this module, usage or code. .PP You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Find::Lib .Ve .PP You can also look for information at: .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2007, 2009 Yann Kerherve, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.