http://qs321.pair.com?node_id=11100985

Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

What are you thoughts about using Cwd::abs_path() instead of $FindBin::Bin?

Motivation

In Mojolicious the auto-generated application script contains:

use FindBin; BEGIN { unshift @INC, "$FindBin::Bin/../lib" }

The issue I have with this is: $FindBin::Bin will not resolve a symbolic link. This can be fine in cases where you want to use different libraries with the same script. Simply create a symbolic link of the script to the location where your different libraries are.

But in my situation I simply wanted to create a symbolic link of the startscript to /usr/local/bin. Of course this is doomed to fail as I will end up with "/usr/local/bin/../lib". But the libraries are in "/app/myapp/lib".

So I've changed it now to

use Cwd 'abs_path'; BEGIN { unshift @INC, abs_path("$0/../../lib") }

Not only will it work in my situation, additionally the "relative part" gets resolved and the path added to @INC will be "/app/myapp/lib".

Questions

  1. Will it fail in any situation you can think of?
  2. Is there any disadvantage in using Cwd instead of FindBin?
  3. What are your thoughts on this matter?

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e