Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

perl

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.

like image 462
Peter Eisentraut Avatar asked Jan 07 '10 11:01

Peter Eisentraut


1 Answers

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

like image 171
lexu Avatar answered Sep 22 '22 15:09

lexu