开发者

How can I find out the file name of a require'd file in Perl?

开发者 https://www.devze.com 2022-12-15 13:57 出处:网络
How do开发者_运维问答 I find out the name of a file that was require\'d, from within that file? I can look into %INC to find the names of all files that were loaded, but I am looking for something lik

How do开发者_运维问答 I find out the name of a file that was require'd, from within that file? I can look into %INC to find the names of all files that were loaded, but I am looking for something like $0 that would serve as the key into %INC.


a simple

my $filename=__FILE__;
print __FILE__;

should do ..

also look here (does-a-perl-module-know-where-it-is-installed) and here ( perldoc on Special-Literals ) for more ideas

0

精彩评论

暂无评论...
验证码 换一张
取 消