I much like:
use Cwd qw(realpath);
use File::Basename;
my ($BIN, $BINPATH);
BEGIN { $BIN = basename($0); $BINPATH = realpath($0) }
over
FindBin.
We simply take
$BIN = basename($0) to ensure wrapper scripts work well. Often,
$0 is symlinked to the actual executable -- we'd like to refer to the base filename as the basename of the symlink path, not the basename of the actual resolved
$BINPATH.