An execution error occurs when a Perl program that performs Web access that has been confirmed to work is run in a certain environment.
Error when accessing the Web via HTTP
$ perl test.pl
501 Attempt to reload IO/Socket.pm aborted.
Compilation failed in require
Error when accessing the Web via HTTPS
$ perl test.pl
LWP will support https URLs if the LWP::Protocol::https module
is installed.
test.pl
#!/usr/bin/perl
use LWP::UserAgent;
my $url = "https://www.example.com";
my $request = HTTP::Request->new(GET => $url);
my $useragent = LWP::UserAgent->new;
my $response = $useragent->request($request);
my $result = $response->content;
print $result;
Perl has been installed with the yum command in a proven way, and the required libraries are installed as well. However, an execution error occurs.
$ sudo yum install perl
$ sudo yum install perl-Net-SSLeay
$ sudo yum install perl-Crypt-SSLeay
$ sudo yum install perl-IO-Socket-SSL
$ sudo yum install perl-IO-stringy
$ sudo yum install perl-URI
$ sudo yum install perl-LWP-Protocol-https
Compared to a working environment, I found that the Perl package did not have perl-Socket installed. Installing this package with the yum command will solve it easily!
$ sudo yum install perl-Socket
It is a package that is usually installed as a dependency, and I have never installed it individually, but it may be that the environment I was using was RHEL7 installed in a certain cloud and had a problem with package management. ..
Recommended Posts