[LINUX] [RHEL7 / CentOS7] LWP execution error in the environment where Perl is installed with the yum command

An error has occured

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.

Applicable Perl script

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 environment built in advance

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

Causes and countermeasures

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

[RHEL7 / CentOS7] LWP execution error in the environment where Perl is installed with the yum command
Implemented pix2pix in Windows environment (with kind command line execution results and common error examples)
A story when a directory is buggy with the django-admin start project command in a virtual environment using Pipenv
Notify using Notification Center when the execution environment is macOS in Python
I installed Pygame with Python 3.5.1 in the environment of pyenv on OS X
De-VBA Excel tool! Eliminate VBA tool with Python in environment where Python cannot be installed
Prepare the execution environment of Python3 with Docker
Error when entering virtual environment with workon command