Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://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).
This might make sense if you consider the standard layout of some code:
In that case,
Is equivalent to:
Or effectively,
This might also make more sense and seem more useful when you also are calling myscript.pl 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
|
|