In Perl 5.24.1 what is the difference between using use liband lib->import? I see that both are used to add a directory to @INC. I am using Perl stock without add-ons. I read http://perldoc.perl.org/lib.html and I am not very good at all ways to use it.
use lib
lib->import
@INC
Here is an example:
In the following code example, the first use libalways works, while the second lib->importdoes not work in my code. I see that it works in different code on the same machine.
#!/usr/bin/perl -T use warnings; use diagnostics; use strict; # new perl 2.24.1 requires FindBin use FindBin; print "found: $FindBin::Bin\n"; #This always works: #use lib $FindBin::Bin; #why does this not always work? #lib->import($FindBin::Bin); foreach my $var(@INC){ print "$var \n"; }
use lib EXPRloads lib.pm, and at compile time calls lib->import(EXPR).
use lib EXPR
lib->import(EXPR)
lib->import(EXPR) , , lib.pm , . ( import() unimport() , .) , BEGIN, , @INC , use.
use
use lib $FindBin::Bin;
():
BEGIN { require "lib.pm"; lib->import($FindBin::Bin); }
/ lib.pm ( , BEGIN).
lib->import(...) , , lib , "", . lib , require ( eval "use ..."). , , , , , .
lib->import(...)
require
eval "use ..."
Source: https://habr.com/ru/post/1669773/More articles:How to display the update transferred from the server to the web page without updating? - pythonIt seems a random accident somewhere deep inside ART - androidVisual Studio updates binaries of a project that is not intended - c #Scala - Simple Futures-Performance Comparisons - scalaC ++ inheritance superclass function call - c ++В какой области необъявленная переменная используется глубоко в коде? - scopeИспользование SearchField Inside Popover продолжает издавать "select" Event and Rerenders Popover - sapui5Filter groups that do not have enough lines that satisfy the condition - pythonSkip structure field during serialization - rustAndroid Studio annoys popup for layout_width and layout_height - androidAll Articles