I'd like to get the full filename of an included module. Consider this code:
package MyTest;
my $path = join '/', split /::/, __PACKAGE__;
$path .= ".pm";
print "$INC{$path}\n";
1;
$ perl -Ipath/to/module -MMyTest -e0
path/to/module/MyTest.pm
Will it work on all platforms?
perlvar
The hash
%INC
contains entries for each filename included via thedo
,require
, oruse
operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found.
Are these keys platform-dependent or not? Should I use File::Spec
or what? At least ActivePerl on win32 uses /
instead of \
.
Update: What about %INC
values? Are they platform-dependent?