|Syntactic Confectionery Delight|
Cwd::abs_path or FindBin::Bin?by Skeeve (Parson)
|on Jun 05, 2019 at 06:34 UTC||Need Help??|
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?
In Mojolicious the auto-generated application script contains:
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
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".