Reputation: 6186
I have a perl module /x/y/z/test.pm
. Inside this module, I want to read a config file /x/y/z/test.config
. Yet, I am including my module from /a/b/c/mymain.pl
. How can I get /x/y/z/
to build the path for /x/y/z/test.config
in /x/y/z/test.pm
?
Thanks,
Upvotes: 0
Views: 76
Reputation: 8198
AFAIK FindBin
will show mymain.pl
(and it might have been used in other modules, then the first invocation will win). Try __FILE__:
my $path = __FILE__;
$path =~ s/pm$/config/;
Upvotes: 3