|Perl Monk, Perl Meditation|
Path relative to packageby DreamT (Pilgrim)
|on Jun 01, 2018 at 14:49 UTC||Need Help??|
DreamT has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have the following components:
1. A package, /App/Package.pm . The task of the package includes opening a file.
2. A config file, located in a subfolder: /App/Config/Config.json.
3. A script that can be located outside the directory structure.
My problem occurs when I try to read the config file; The problem is that I don't know the relative path between the package and the config file.
• I know that I can use FindBin to get the path to the executing script - But I want the package to figure out the path "on it's own". It should be aware of the path to the config file without depending on the calling script
• I also know that the path is available in @INC (via use lib...). But I don't know how to get the correct one from here. I guess that I could regex it, but...I'm looking for a more secure method to obtain it.