The problem with the grill tool

I downloaded and installed the perl tool (trellis tool). But it is in my local directory. While I run, he says that he cannot find Directed.pm (the lib file), which is available in the lib folder of my local directory. Hope it will be set correctly if I set the path variable. If so, how to install it?

+4
source share
4 answers

To use lib, you must use the full path, and you should not use the relativ path like this.

use '../lib';#not working in all times. 

Scenario: your scripts in /bin/prog.pl, your lib is something / lib / lib.pm.

If you use the relativ path, you should call your program as follows:

 cd something/bin/ && ./prog.pl 

If you want to use the relativ path, use FindBin to find your current path:

 use FindBin; use lib "$FindBin::Bin/../lib";#your lib realitv to your script use lib $FindBin::Bin;#your current script full path 

Then you could call your program from anywhere where it always finds its lib realiv for itself.

 cd ~ something/bin/prog.pl# ti will use the correct lib 
+2
source

In my scenarios, I have the following (which I am sure can be improved, but it still works):

 my $mydir; BEGIN { ($mydir) = ($0 =~ m#(.*)[/\\]#) or $mydir = '.'; } use lib "$mydir/lib"; 

So, the script tries to define its own directory, and then tells Perl to look for libraries in the lib subdirectory of that directory.

+1
source

You need to add 'lib' to the perl directory for modules. You can do this with the -I flag:

  perl -Ilib lattice-tool.pl 
0
source

Use lib :

 use lib 'lib'; 

lib also checks architecture-specific subdirectories under lib to make sure that machine-specific files are loaded.

EDIT: Note that the directories passed to lib refer to your current working directory, so if you want to execute your script from another place, you should use use lib '/home/user1126070/lib' .

From perlvar :

 The array @INC contains the list of places that the do EXPR , require, or use constructs look for their library files. It initially consists of the arguments to any -I command-line switches, followed by the default Perl library, probably /usr/local/lib/perl, followed by ".", to represent the current directory. ("." will not be appended if taint checks are enabled, either by -T or by -t .) If you need to modify this at runtime, you should use the use lib pragma to get the machine-dependent library properly loaded [...] 
0
source

Source: https://habr.com/ru/post/1393928/


All Articles