Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
FindBin allows you to retain the flexibility of the relatives paths, with the additional benefits of absolute paths. FindBin simply figures out the precise location of the script and allows you to do things like use lib during run time. Managing PERL5LIB can be cumbersome, particular if you are distributing a Perl program that can be put anywhere on someone's system. FindBin allows you to assume the location of libraries with respect to the Binary (your script). This allows you to reason about them absolutely with the flexibility of not knowing where your script is located. What's the alternative? Doing what you've done, setting PERL5LIB explicitly. FindBin would allow you to never have to set this explicitly again (or if you were distributing your code, make your users set PERL5LIB).
use FindBin; use lib "$FindBin::Bin/../lib";

This might make sense if you consider the standard layout of some code:

/path/to/my/bin/ /path/to/my/lib/

In that case,

use FindBin; use lib "$FindBin::Bin/../lib";

Is equivalent to:

use FindBin; use lib "/path/to/my/bin/../lib";

Or effectively,

use FindBin; use lib "/path/to/my/lib";

This might also make more sense and seem more useful when you also are calling by virtual of /path/to/my/bin being in your PATH.

In reply to Re^5: Instance of 'use lib' won't accept relative path by perlfan
in thread Instance of 'use lib' won't accept relative path by Lady_Aleena

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2021-11-28 13:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found