I am writing a Perl script which does -
- SSH to one of the server and do some operation using
Net::OpenSSHPerl Module. - I want to have entire log of the script to be stored in certain log file using
Log::Log4perlPerl Module. - I want to write some data to CSV file using
Text::CSVPerl Module.
Actually these three Perl Modules have been installed in different directories.
Lets say -
Net::OpenSSHis installed in /path/to/lib1Log::Log4perlis installed in /path/to/lib2Text::CSVis installed in /path/to/lib3
Since these Perl Modules has been installed in different locations, I am mentioning the respective paths in Shebang line like below:
Method1:
#!/usr/bin/perl -I/path/to/lib1 -I/path/to/lib2 -I/path/to/lib3
use strict;
use warnings;
use Net::OpenSSH;
use Log::Log4perl;
use Text::CSV;
#continue flow of the script
..
This works perfectly fine for me.
I found one more method to call these Perl modules like below:
Method 2:
#!/usr/bin/perl
use strict;
use warnings;
use lib '/path/to/lib1';
use lib '/path/to/lib2';
use lib '/path/to/lib3';
...
Above method also works fine for me.
I found the standard way to call these Perl modules by the use of FindBin.
I am confused with its syntax. How can I achieve same using FindBin Perl Module.
Method 3:
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin/path/to/lib1";
use lib "$Bin/path/to/lib2";
use lib "$Bin/path/to/lib3";
...
This throws me following error which doesn't appears when I use first two methods (Method1, Method2).
unable to load Perl module IO::Pty: Can't locate IO/Pty.pm in @INC ...
Where I am doing wrong in Method 3?