I'm using Sublime Text 2 editor for Perl development and now I faced next problem. I have my project under:
/home/alex/workspace/
In this project I have libraries under:
/home/alex/workspace/lib/
While I'm editing file:
/home/alex/workspace/test.pl
and in this file I try to load library:
/home/alex/workspace/lib/myLib.pm
I have a code like this:
#!/usr/bin/perl
use myLib;
sublimelinter is not able to find this library because it is not in default @INC path. Is there any way to modify Perl's @INC for sublimelinter without changing my scripts source code?
I tried to use per-project settings for linter like this:
{
"folders":
[
{
"path": "/home/alex/workspace"
}
],
"settings":
{
"SublimeLinter":
{
"Perl" :
{
"lint_args":
[
"-I", "/home/alex/workspace/lib",
"-c",
"{filename}"
]
}
}
}
}
But this does not help.
These answers should be updated for sublime text 3
Open Preferences-> Package Setting->SublimeLinter->Settings-User.
Find this entry, and replace /path/to/my/project
"linters": {
"perl": {
"include_dirs": ["/path/to/my/project"]
}'
This should work. There may be better practices though, I'm not an expert.
#!/usr/bin/perl
use strict;
use warnings;
use lib "/home/alex/workspace/lib/";
use myLib;
Here's a link: http://perldoc.perl.org/lib.html
This would have some portability issues, but this question has some other related answers: How can my Perl script find its module in the same directory?
Another good source http://learn.perl.org/faq/perlfaq8.html#How-do-I-add-a-directory-to-my-include-path-INC-at-runtime-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With