I have a folder with several .pl
files that run through main.pl
. I have successfully had these working by using require 'file.pl';
at the beginning of the main file. I have used some modules, too, without issue.
I am now trying to use a 'home-made' module, but when I add use Add::Location::CSearch qw(c_search);
to the top of the file that it is being used in (or the top of the main file) and run the main file, it produces the Can't locate file.pl in @INC...
error with file.pl
being the first file in the require
list in the main file.
From how I understand it, after adding the use
line it now tries to find all the require
in that same directory. The (@INC contains: ...)
at the end of the error message lists some library/module folders. It also has .
at the end for the current directory.
I hope I have explained this well; it is confusing! I don't know why this happens and how to solve it, so I would be grateful for any ideas.
Edit: Sample Code
main.pl
#!/usr/bin/perl
package testpack;
use lib '/hlib/...';
use Add::DB;
use List::Util qw(sum);
use List::MoreUtils qw(uniq);
use List::MoreUtils qw(firstidx);
use strict;
use warnings;
require 'file1.pl';
require 'file2.pl';
require 'file3.pl';
.
.
.
file1.pl
#!/usr/bin/perl
package testpack;
use Add::Location::CSearch qw(c_search);
This is all that really counts for the problem... the rest of the files have working code that calls subroutines etc.