[tpm] Detect a module's directory

Digimer linux at alteeve.com
Mon Feb 22 11:28:01 PST 2010

Hi all,

   Possibly stupid question time...

   Is there a reliable* way to detect or read the directory that a perl 
module is in? '$ENV{PWD}' returns the directory of the script loading 
the module, not of the module itself. My Google-fu is failing me as 
finding a solution, too.

   The reason I need this is that my core module reads in a 
configuration file from the root of the module's directory. I could 
hard-code it, but I would rather it be flexible in case it gets moved 
down the road.



*Reliable in that it'd work when run from cron, work if/when the module 
is moved, etc.

More information about the toronto-pm mailing list