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;