1

I have installed Bundle::LWP and after several minuets I'm getting this

$ perl -MLWP -le "print(LWP->VERSION)"
6.68

which sounds OK. However, running this script

#!/usr/bin/perl


# Example code from Chapter 1 of /Perl and LWP/ by Sean M. Burke

# http://www.oreilly.com/catalog/perllwp/

# [email protected]


require 5;

use strict;

use warnings;


use LWP;


my $browser = LWP::UserAgent->new();

my $response = $browser->get("http://www.oreilly.com/");

die "Couldn't access it: ", $response->status_line

 unless $response->is_success;

print $response->header("Server"), "\n";

__END__

gives this Error:

$ perl a3.pl
Couldn't access it: 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) at a3.pl line 25.

How can I fix it ?

1 Answer 1

1

You need to install LWP::Protocol::https Perl's module with:

cpan LWP::Protocol::https

or use package manager, on Debian and derivative:

apt install liblwp-protocol-https-perl

It's because O'Reilly default now serve the page in https with a redirection, see curl -v bellow:

$ curl -v "http://www.oreilly.com/"
*   Trying 104.85.21.198:80...
* Connected to www.oreilly.com (104.85.21.198) port 80 (#0)
> GET / HTTP/1.1
> Host: www.oreilly.com
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Server: AkamaiGHost
< Content-Length: 0
< Location: https://www.oreilly.com/
5
  • How can I print more lines than the word Apache in that code here: print $response->header("Server"), "\n"; ? Commented Apr 27, 2023 at 14:09
  • Turn next pages and if you are stuck, post a new question =) Commented Apr 27, 2023 at 14:14
  • Could you write down here for me the page number where can I find this ? I believe that checking a hint is easier than finding it by myself, i.e. that P<>NP :-) Commented Apr 27, 2023 at 14:16
  • 1
    I don't have the book. If you learn Perl, do it properly. You should definitely ask a new question if you want a response that is off topic in this comments. I will make a response (or anyone else) Commented Apr 27, 2023 at 14:19
  • Here it is a new question. Commented Apr 27, 2023 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .