user3197375
user3197375

Reputation: 21

Why perl cgi does not compile CPAN module

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

Upvotes: 1

Views: 220

Answers (1)

user3197375
user3197375

Reputation: 21

Thank you for those who provided comments. I have used the advice given by Grinnz who pointed me to the use of 'use lib /path /to /module' By using the use lib statement with the path to the Template module as the second line of the script and before the use HTML::Template statement, the script worked perfectly. Thanks again.

Upvotes: 1

Related Questions