lib_file#
דיווח באיזה נתיב מפרש זה רואה קובץ ספרייה.
תקציר#
use Config;
my $path = Config::lib_file("strict.pm");
my $path = Config::lib_file("ExtUtils/typemap");
my $path = Config::lib_file("Foo/Bar.pm", \@dirs);
מה מוחזר#
הנתיב של הקובץ ש־require של השם הזה היה טוען, או undef כאשר אין כזה. השם הוא נתיב מתחת לספריית ספריות, עם / בין החלקים, כמו ב־%INC. אפשר לפתוח את הנתיב.
A file that is part of the pperl binary is found first and reported under $Config{privlibexp}, the directory that holds the binary’s library: nothing elsewhere can take its place. Any other file is looked for in each directory of @INC in turn, and the first one that exists and is not a directory is reported.
With a second argument, a reference to an array of directories, those are searched in place of @INC. The pperl binary’s own files count only when $Config{privlibexp} is among them.
למודול מובנה שנכתב ב־Rust אין קוד מקור ב־Perl. כשהוא נפתח בנתיב שמדווח כאן, הוא נקרא כשלוש שורות: החבילה שלו, ה־$VERSION שלו וערך אמת.
מדוע היא קיימת#
Perl’s own way of asking is to walk @INC with -e or -r and take the first hit. That walk works on pperl too, but the first file test of the binary’s library writes it to disk, and a walk cannot see that a built-in module wins over a copy in an earlier directory. A tool that must know where a module is, or which version would be loaded, asks here, and nothing is written.
דוגמאות#
use Config;
use ExtUtils::MakeMaker ();
my $file = Config::lib_file("List/Util.pm");
print MM->parse_version($file), "\n" if defined $file;