FindBin is the standard way to find where you are and resolve all symlinks. It's core module.
I think there can be issues with dirname($0) with symlinks.
use FindBin;
use Cwd 'abs_path';
my $script_path = abs_path($FindBin::RealBin); # from a script in scripts/
my $script_path = abs_path("$FindBin::RealBin/../scripts"); # from PIRATE
use File::Basename;
my $exe_name = basename("$FindBin::RealScript"); #
FindBin
is the standard way to find where you are and resolve all symlinks. It's core module. I think there can be issues withdirname($0)
with symlinks.