My OS is Debian Buster. My cgi-bin is in /var. The CPAN module is HTML::Template and located in /perl5/lib/perl5/HTML as installed by cpanm. My server is Apache2 and appears to be configured correctly by all the research I have done (but something must be wrong somewhere). My browser is Firefox , but I also use curl for testing. I can run cgi perl scripts without perl modules from localhost/cgi-bin/ successfully. I can run perl scripts WITH 'use HTML::Template' from the command line with ./ with perfect HTML output BUT, AND THIS IS THE PROBLEM I cannot run these from localhost either with the browser or curl when they include a perl module such as HTML::Template.
The Apache2 error message is BEGIN failed--compilation aborted at /var/cgi-bin/templateOne.cgi line 5.: /var/cgi-bin/templateOne.cgi [Wed Oct 16 00:01:23.341309 2019] [cgi:error] [pid 3743] [client ::1:36728] End of script output before headers: templateOne.cgi
Now line 5 of the script is use HTML::Template;
So it fails to either locate or compile the module, but since the program works perfectly from the command line then Apache2 I assume is unable to locate the module.
I have tried using push(@INC, '//Perl5/lib/perl5/HTML'); at the start of the script but this does not work either.
Does any one have a suggestion
perl5
in the root directory. File paths are also case sensitive. It also looks up based on the whole module name so the library path you are actually looking for is/home/youruser/perl5/lib/perl5
. – Grinnz@INC
manually, use lib or you will not get version and arch specific instllations (such as XS code). – GrinnzPERL5LIB
environment variable for CGI scripts. – GrinnzBEGIN failed--compilation aborted
is never the first error message; what error are you actually getting? – ikegamipush(@INC, '//Perl5/lib/perl5/HTML')
should beuse lib '/perl5/lib/perl5';
You might be modifying@INC
too late --use lib
will change it at compile-time -- you misspelledperl5
, and you shouldn't have includedHTML
. – ikegami