in reply to Location reference - programming style

You could look in %INC to find where Location B might be. You'll need to slightly transform the B module name (use slashes instead of double colons and append .pm) to do the lookup. For some idea of what to expect...

perl -MData::Dumper -e "print Dumper \%INC"

gives

$VAR1 = { 'warnings/register.pm' => '/System/Library/Perl/5.10.0/warni +ngs/register.pm', 'bytes.pm' => '/System/Library/Perl/5.10.0/bytes.pm', 'XSLoader.pm' => '/System/Library/Perl/5.10.0/darwin-thread- +multi-2level/XSLoader.pm', 'Carp.pm' => '/System/Library/Perl/5.10.0/Carp.pm', 'Exporter.pm' => '/System/Library/Perl/5.10.0/Exporter.pm', 'warnings.pm' => '/System/Library/Perl/5.10.0/warnings.pm', 'overload.pm' => '/System/Library/Perl/5.10.0/overload.pm', 'Data/Dumper.pm' => '/System/Library/Perl/5.10.0/darwin-thre +ad-multi-2level/Data/Dumper.pm' };

Replies are listed 'Best First'.
Re^2: Location reference - programming style
by bart (Canon) on Aug 15, 2010 at 02:43 UTC
    Additionally: If it's module B that wants to know where its file is, you can make use of the __FILE__ token, but only from within the module itself (documented in perldata). That could be in a sub defined in that module which you can call from anywhere.

    Alternatively you could just not care where exactly the config file is stored, and just search for it yourself in @INC.