Thanks for your answer. I tried that, but it didn't work. Also, I'm pretty sure the right path is in INC anyway. Let's say that B.pm is located in /path/A/B.pm, then /path was already in INC so A::B should be resolvable. I added /path/A with your method, but like I said it didn't help.
By the way, I looked in the Apache error_log and it prints another module in front of the error message:
C.pm: Can't locate object method "new" via package "A::B"
I'm very confused as to its role, because although C is loaded before I refer to A::B::new with a "do" statement, it does not link to A::B in any way. Could this provide some insight?
You could try a real short test to check the value of @INC. Also check the value of DOCUMENT_ROOT, because some servers don't set it and in that case you have to spell out the full server path.
Maybe upload the following code as "test.cgi" and then call it up with the browswer and see whatcha got.
-
#!/usr/bin/perl
-
-
print "content-type: text/html\n\n";
-
print "Value of INC is: @INC<br>\n";
-
print "DOCUMENT_ROOT is: $ENV{'DOCUMENT_ROOT'}";
-
exit;
-
Unless the server path, all the way from the server root to your "A" directory, is in the @INC your script won't be found. On my server the @INC was pointed to nothing related to my site. I suggest not assuming anything about INC.
In my case my DOCUMENT_ROOT looks like this,
DOCUMENT_ROOT=/home/username/public_html
That gets me to my root directory, but my library isn't under my root so that isn't sufficient. I put my library under my cgi-bin directory, so I needed to set @INC to include that path, ie,
push @INC, "$ENV{'DOCUMENT_ROOT'}/cgi-bin/library";
I would then have the "A" directory under the "library" directory, and "B" under "A". Then the server can find "A::B".
If the DOCUMENT_ROOT variable was not set by the server I would have to set the @INC array like this,
push @INC, '/home/username/public_html/cgi-bin/library';
(be sure to use capital letters where indicated)
On more than one occasion it has come to my attention that I know less than everything. Therefore, I may be all wet on this matter, but I think your @INC is not pointing correctly. Anyway, printing the value of @INC will reveal the reality and leave one less mystery.