I have this code to print the current directory using Perl:
use Cwd qw(abs_path);
my $path = abs_path($0);
The following get the script's directory, which is not the same as the current directory. It's not clear which one you want.
use Cwd qw( abs_path ); use File::Basename qw( dirname ); say dirname(abs_path($0));
use Path::Class qw( file ); say file($0)->absolute->dir;
use Cwd qw( abs_path ); use Path::Class qw( file ); say file(abs_path($0))->dir;
The middle one handles symlinks different than the other two, I believe.