Take this simple instruction if you need to include module (which is not installed at your system) to your perl script.
- Get module and install it to directory where you have write permission (For example: /home/user1/libs).
- Go to your script and add new library path to your INC array:
- Include it to your script with “require” or “use” directives.
use lib '/home/user1/libs';
to check that it was successfully put in INC array, print it out
print "\@INC = @INC\n";
require "test.pm";
or
use "test.pm";
SAMPLE
Here is some little sample how it’s work.
Our module:
user1@agrytsenko:~/tmp2$ cat lib/test.pm
package test;
use strict;
sub say {
my $word=shift;
my $str="Hello my $word world\n";
return($str);
}
1;
__END__
Our script:
user1@agrytsenko:~/tmp2$ cat bin/test.pl
#!/usr/bin/perl
use lib '/home/user1/tmp2/lib';
require 'test.pm';
my $string=test::say("good");
print $string, "\n";
Our running result:
sheva@agrytsenko:~/tmp2/bin$ ./test.pl Hello my good world