Completely new to debian, linux and sudo based virtual machines. I initially wanted to run this cgi file (printfile.cgi):
#!/usr/bin/perl
use strict;
use CGI;
print "Content-type: text/htmlnn";
my $document_root = "/opt/lampp/htdocs/";
my $cgi = new CGI;
my $filename = $cgi->param('file');
my $filepath = $document_root.$filename;
open(FILE, $filepath);
my @file_in = <FILE>;
foreach(@file_in) {
print $_, "<br>n";
}
close(FILE);
exit;
However, I obtained the error message (Can’t locate CGI.pm in @INC). This was the first issue, I was not able to pin point why, but I assumed CGI.pm was in the /usr based directory or the /opt one. Irregardless, I knew my installation of libcgi-pm-perl was in the wrong directory (where INC is expecting it)
After searching for some workarounds (https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations + https://www.perlmonks.org/?node_id=465764), I initially tried using the use lib method in the aforementioned link, but it could only really find one .pm file.
Next, I tried to improvise by copying the files in the scattered /usr and /opt folders into one that is in @INC (I used /etc/perl).
The main .pm files that the cgi file needed was CGI, Request, Pool and APR. In the case of APR, I did use the ‘use lib’ method in my cgi file. Modifying it to this version which I now use:
#!/usr/bin/perl
use lib '/opt/lampp/lib/perl5/site_perl/5.34.1/x86_64-linux-thread-multi/'; (To look for APR.pm)
use strict;
use APR;
use Request; (Request, Pool and CGI are in /etc/perl)
use Pool;
use CGI;
print "Content-type: text/htmlnn";
my $document_root = "/opt/lampp/htdocs/";
my $cgi = new CGI;
my $filename = $cgi->param('file');
my $filepath = $document_root.$filename;
open(FILE, $filepath);
my @file_in = <FILE>;
foreach(@file_in) {
print $_, "<br>n";
}
close(FILE);
exit;
However, somewhere between moving/copying the .pm files, I managed to accidentally copy the APR.pm into the /etc/perl directory, and recopied it back to the original library/folder (which I forgot, apologies)
Unsure if the modification to the APR file did anything, I obtained a new error message when running printfile.cgi:
APR.c: loadable library and perl binaries are mismatched (got handshake key 0xeb00080, needed 0xce00080)
I referred to these two questions on how to resolve the mismatch, but was confused on how to proceed. (https://www.linuxquestions.org/questions/slackware-14/clone-c-loadable-library-and-perl-binaries-are-mismatched-4175726667/ and ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xdb80080))
If I am not mistaken, I have to reinstall the APR.pm file, aka the whole libapache2-mod-perl2 package to rectify the mismatch.
I hope to find some answer to my issue, apologies if I sound inexperienced.
Bentley Teng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.