importing an class from the same directory in Perl [duplicate] - linux

This question already has answers here:
Doesn't Perl include current directory in #INC by default?
(3 answers)
Closed 3 years ago.
i have a directory with main.pl and Product.pl. in the main.pl i try to import the Product class but the execution fails when i run perl main.pl complaining that cant locate Product.pm in #INC. My directory is not in the #INC list. How can i fix this?

Create a local subdirectory, name it lib and put your module file there. On newer Perls you must tell Perl to include that local directory to #INC, either by adding it to PERL5LIB (environment variable) somehow, or by adding
use lib qw( . );
to the script that wants to load that module. If you are paranoid you can also use an absolute path.

You already got some help in complain that module's filename should end in .pm. Now you need to look for the purpose of variable PERL5LIB=???.
PERL5LIB

Related

How to Call Custom Perl Module in a Script

I am installing mireap software on my Linux VM (https://sourceforge.net/projects/mireap/). After installation, I am unable to run the software as I am always getting the error that FFW1.pm module needs to be installed; however, the module is present in lib directory. The script failed to call the module from the library. I will really appreciate if you help me in this regard. The steps which I performed are there in the image.
It's not clear what you mean by "lib directory".
If you mean the the module is in a directory named lib, and that this directory is a subdirectory of the one in which the script is located, then this should be added to the script:
use FindBin qw( $RealBin );
use lib "$RealBin/lib";

Ubuntu doesn't recognice any command [duplicate]

This question already has answers here:
Linux wrong path exported. How to recover ~./bashrc file
(2 answers)
Closed 4 years ago.
First of all, i was installing CUDA with cuDNN, the thing is that i put some new paths on the ~/.bashrc after that all the commands like ls, sudo, etc. doesn't work, it shows this message
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found
Do anyone knows what is the issue?
You need to include the /usr/bin path in your PATH environment variable because this is where the ls, cd & all others built-in commands are located.
The easiest way is to update your PATH environment variable with the export method :
export PATH="$PATH:/usr/bin"
If the export method doesn't work for you, you can edit your .bashrc file (nano ~/.bashrc) and update the PATH variable by adding the /usr/bin path in it.
Good luck

Run Rust program without cargo run [duplicate]

This question already has answers here:
How do I make a Rust program which can be executed without using `cargo run`?
(4 answers)
Closed 8 months ago.
I built a simple CLI written in Rust that executes with the command cargo run <ARGUMENTS>. I want to be able to run the CLI from any directory. I used the clap crate and want to be able to call the script with the name passed to clap: brainfast <ARGUMENTS>. I am running on macOS.
This is more like a generic question (and I think a duplicate too, but I can't find any).
You have to copy your executable that is generated by cargo build --release (you can find it in target/release/crate_name) to a folder in your $PATH.
I'm not an expert in macOS, so I can't tell you what is a folder that is included in the $PATH, but you can find that out by yourself by opening a terminal and typing echo $PATH. Use one of the paths and it should be available in your terminal without cargo or using any path.
As an alternative, you can add a folder to your $PATH variable and put it there, e.g.
export PATH /home/foobar/.bin:$PATH
cp target/release/brainfast /home/foobar/.bin
brainfast abc.txt 1 3 99 u

Installed Module not contained in the Perl's #INC path

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
BEGIN
{
push(#INC, '/home/penny/perlModules');
}
use my::module;
use File::Path;
...
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.

julia: system image file "sys.ji" not found

I am using the IDE Netbeans to code a project c++ under Linux(red hat 7). As I need to use some math functions, I try to embed the julia language into my c++ project.
Here is what I have done:
Download the Julia from here (I choose this: Generic Linux binaries)
Set project properties: build-->C++ Complier-->Include Directories, add the include of Julia, something like this: ../myjulia/include/julia
Add the libraries: open a terminal and type the command line: sudo ln -s ../myjulia/lib/julia/libjulia.so /usr/lib/libjulia.so
Now if I run my project, I will get this error: System image file "../myproject/dist/Debug/GNU-Linux-x86/../lib/julia/sys.ji" not found
I hve checked this file: ../myjulia/lib/julia, in this file, there are all of the lib files (libjulia.so etc) and a file named "sys.ji".
I ran into this issue after installing Julia v0.3.10 on a Windows machine and thought I'd post it in case it can help someone else.
When I ran julia.exe it gave me the error message listed above.
Problem:
I had created a system environment variable called JULIA_HOME and pointed it to the directory where Julia was installed. Then, I added %JULIA_HOME%\bin to my PATH.
Solution:
I pointed JULIA_HOME to the \bin directory under the Julia install directory. Then, I added %JULIA_HOME% to my PATH
A "hello world" example from here
Now we know that we need to setup the julia context with this code:
jl_init(NULL);
In fact this code may not setup a good context because the project can't find the system image file "sys.ji". So what we need to do is using another function instead of jl_init: jl_init_with_image. This function accept two parameters: the first is the path of the image file, the second is the name of the image file. So we should use it like this: jl_init_with_image("/thePathOfSys.ji", "sys.ji"); One more thing: the path of sys.ji must be the absolute path.

Resources