#!perl use Cwd qw( getcwd abs_path ); my ($DIR, $CMD) = $0 =~ m{^(.*)/([^/]+)$}; ! $CMD && ! -d $DIR and ($DIR, $CMD) = (getcwd, $DIR); # "." in $PATH and script invoked without ./ -l $DIR or die "$DIR is not the symlinked folder. Running like this is dangerous!\n"; say "Current dir : ", getcwd; say "Invoking folder: ", $DIR; say "Symlink : ", readlink $DIR; say "Abs path: : ", abs_path $DIR;