I have an issue on including the Excel-Writer-XLSX module in the @INC path. I did some research before posting this question and tried several solutions, but they all failed.
So I did
$sudo perl -MCPAN -e 'install Excel::Writer::XLSX'
But after I run the code, I got this message
--can't locate Excel/Writer/XLSX.pm in @INC(you may need to install the Excel::Writer::XLSX module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level/...)
This is not a duplicate question, because the Excel::Writer::XLSX module has been successfully installed in my computer and I don't need to install it again. The thing is when I checked my library folder, the perl5 folder is not there, as it was suggested by the @INC path. Instead, Perl5 folder is in my user folder...and actually the module can be found in the lib folder inside the perl5 folder
I'm not quite sure what is happening...Why the @INC path shows the perl/5.18 is inside the library folder? If you know how to solve this issue, please advice. Thank you so much!
Make sure the @INC contains the path where your modules are getting installed. You can specify that by
export PERL5LIB=/home/foobar/code
(For Linux) (Add this to ~/.bashrc to make it always available when you log-in.)set PERL5LIB = c:\path\to\dir
(For Windows)Also see:
How do I 'use' a Perl module in a directory not in @INC?
How to change @INC to find Perl modules in non-standard locations
At the very top of your perl code right after #!/usr/bin/perl
This will allow your code to use any module you've installed in perlModules dir.
Downside is you have to modify code. Or you can use PERL5LIB env path as answered above.