I have already installed Spreadsheet::ParseExcel and Spreadsheet::WriterExcel by CPAN. When I run the perl script in command line, it runs well and return as expected. However, As run as CGI script(result.pl) by Web browser, the error messages shows

[cgi:error] [pid 4778] [client 192.168.1.104:52082] AH01215: Can't loc +ate Spreadsheet/ParseExcel.pm in @INC (@INC contains: /usr/local/lib6 +4/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/shar +e/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /var/www/ +cgi-bin/result.pl line 11.

I am sure the Spread modules are installed, and find them as the below directory:

[root@localhost ~]# find / -name 'Parser.pm' /usr/share/perl5/vendor_perl/TAP/Parser.pm /home/phillip/.cpan/build/HTML-Parser-3.72-Vmh_1r/Parser.pm /home/phillip/.cpan/build/HTML-Parser-3.72-Vmh_1r/blib/lib/HTML/Parser +.pm /home/phillip/perl5/lib/perl5/x86_64-linux-thread-multi/HTML/Parser.pm

As googled items, I try to add the path to @INC by

#result.pl use lib qw(/home/phillip/perl5/lib/perl5); use Spreadsheet:ParseExcel;
the http error_log still shows
"[cgi:error] [pid 1055] [client 192.168.1.104:56670] AH01215: Can't lo +cate Spreadsheet/ParseExcel.pm in @INC (@INC contains: /home/phillip/ +perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/li +b64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 / +usr/share/perl5 .) at /var/www/cgi-bin/result.pl line 10., referer: h +ttp://192.168.1.143/ [Thu May 09 00:02:21.333414 2019] [cgi:error] [pid 1055] [client 192.1 +68.1.104:56670] AH01215: BEGIN failed--compilation aborted at /var/ww +w/cgi-bin/result.pl line 10., referer: http://192.168.1.143/"

Why run well in command line by root, and why failed by web browser? I guess perhaps it is caused by privileges, apache user can not invisit the part which owner is root. Would you please give any hint? How to resolve this? Thanks in advanced,

PH

2019-05-09 Athanasius fixed code tags


In reply to Apache/CGI fcould not use Spreadsheet::ParseExcel by PhillipHuang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.