in reply to Re^2: Can't locate object method "new" via package "LWP::Protocol::https::Socket"
in thread Can't locate object method "new" via package "LWP::Protocol::https::Socket"

Can't load 'C:/Strawberry/perl/site/lib/auto/Net/SSLeay/SSLeay.xs.dll' for module Net::SSLeay: load_file:The specified module could not be found (LWP::Protocol::https not installed)

The (second) script that you provided works fine for me on 64-bit Strawberry Perl 5.32.1.1. I'm therefore pretty certain that there's something broken in your environment - perhaps some interference from some old perl installation.

I think you should be able to reproduce that error by simply trying to "use Net::SSLeay" :
perl -MNet::SSLeay -e 1
I added a bit to your script, to reveal the contents of $response:
use LWP::UserAgent; use HTTP::Request::Common; $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; my ($response_content, $response_status); my $userAgent = LWP::UserAgent->new(); $userAgent->agent("PhilPerl"); my $request = HTTP::Request->new(); $request->method('GET'); $request->uri('https://perlmonks.org'); my $response = $userAgent->request($request); if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; }
For me, that worked fine and successfully retrieved the requested page.

Even if I effectively remove LWP::Protocol::https (by renaming perl/vendor/lib/LWP/Protocol/https.pm to perl/vendor/lib/LWP/Protocol/https.pm_hide) the script still runs fine.
However, in this instance, $response merely contains the message "501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) at try.pl line 21."

In addition to the checks already mentioned, take a look at what's in your PATH (perl -le "print $ENV{PATH}) as that's what SSLeay.xs.dll searches (in sequence) for the dlls it needs.
And it will load the first one it finds whose name (case-insensitively) matches the name it's looking for.

Your SSLeay.xs.dll needs to load msvcrt.dll, kernel32.dll, libcrypto-1_1-x64__.dll, libssl-1_1-x64__.dll and perl532.dll.
The first 2 are system files - there should be no problem there.
The last one is the perl-5.32.x dll - there should be no problem there unless there's another perl532.dll found earlier in the path.
And the remaining 2 are given such StrawberryPerl-specific names that it's very unlikely there's a problem there.
It's a bit of a mystery !!

Cheers,
Rob

Replies are listed 'Best First'.
Re^4: Can't locate object method "new" via package "LWP::Protocol::https::Socket"
by Philbert (Novice) on Jul 12, 2022 at 18:04 UTC

    As at least two of you pointed out, I could reproduce the error easily by useing either LWP::Protocol::https or Net::SSLeay .

    I owe you all an apology. I've lurked here long enough to know how much care you put into your responses, and yet I neglected to mention that my scripts are running under IIS. While I could reproduce the error by using either of the above mentioned modules, they both load fine from the command line.

    This is resolved. With your suggestions I realized that my command line and IIS $ENV{path} values didn't match. Reason being the machine is already in production so I didn't want to restart IIS, and Strawberry Perl was installed after IIS was started, so IIS and the Perl processes that it spawned had a few paths missing.

    Thanks everyone.