In Perl, how do I get the directory or path of the current executing code?
perl
Solution
The `__FILE__` token will give you the full path including the file name. You can use File::Spec to split it into components:
my ($volume, $directory, $file) = File::Spec->splitpath(__FILE__);
Problem
If I am in some library code, how do I determine the path to the file of the code that is currently executing? I know how to get the path of the top perl file by looking at `ARGV`, but if I load a library, how can that library know which path it is at?