Add custom path to Perl libraries for SublimeLinter

I am using the Sublime Text 2 editor to develop Perl, and now I am facing the following problem. I have a project:

/home/alex/workspace/ 

In this project, I have libraries under:

 /home/alex/workspace/lib/ 

While I am editing the file:

 /home/alex/workspace/test.pl 

and in this file I am trying to load the library:

/home/alex/workspace/lib/myLib.pm

I have a code like this:

 #!/usr/bin/perl use myLib; 

sublimelinter cannot find this library because it is not located by default on the @INC path. Is there a way to change Perl @INC for sublimelinter without changing the script source code?

I tried using for project parameters for linter as follows:

 { "folders": [ { "path": "/home/alex/workspace" } ], "settings": { "SublimeLinter": { "Perl" : { "lint_args": [ "-I", "/home/alex/workspace/lib", "-c", "{filename}" ] } } } } 

But that does not help.

+4
source share
2 answers

These answers must be updated for exalted text. 3

Open Settings-> Package Settings-> SublimeLinter-> Settings-User.

Find this entry and replace / path / with / my / project

  "linters": { "perl": { "include_dirs": ["/path/to/my/project"] }' 
+1
source

That should work. However, there may be best practices; I am not an expert.

 #!/usr/bin/perl use strict; use warnings; use lib "/home/alex/workspace/lib/"; use myLib; 

Here's the link: http://perldoc.perl.org/lib.html

This would have portability problems, but this question has other related answers: How will my Perl script find its module in the same directory?

Another good source is http://learn.perl.org/faq/perlfaq8.html#How-do-I-add-a-directory-to-my-include-path-INC-at-runtime-

+2
source

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


All Articles