Logo

dev-resources.site

for different kinds of informations.

How to download cpanm in the portable way that supports Perl 5.8.1

Published at
12/12/2022
Categories
beginners
perl
cpan
cpanm
Author
yukikimoto
Categories
4 categories in total
beginners
open
perl
open
cpan
open
cpanm
open
Author
10 person written this
yukikimoto
open
How to download cpanm in the portable way that supports Perl 5.8.1

How to download cpanm in the portable way that supports Perl 5.8.1.

On Linux/UNIX, Mac, Windows/PowerShell

perl -0777 -Mstrict -Mwarnings -MIO::Socket::INET -e 'my $socket = IO::Socket::INET->new(  Proto => qq(tcp),  PeerAddr => qq(cpanmin.us),  PeerPort => 80,) or die $!;print $socket join qq(\r\n),  qq(GET / HTTP/1.1),  qq(Connection:close),  qq(Host:cpanmin.us),  qq(\r\n);my $res = <$socket>;$res =~ m(^HTTP/1\.1 200 OK\r\n) or die $res;$res =~ s/.*?\r\n\r\n//s;open my $out, qq(>), qq(cpanm) or die $!;print $out $res'
Enter fullscreen mode Exit fullscreen mode

On Windows/Command Prompt:

perl -0777 -Mstrict -Mwarnings -MIO::Socket::INET -e "my $socket = IO::Socket::INET->new(  Proto => qq(tcp),  PeerAddr => qq(cpanmin.us),  PeerPort => 80,) or die $!;print $socket join qq(\r\n),  qq(GET / HTTP/1.1),  qq(Connection:close),  qq(Host:cpanmin.us),  qq(\r\n);my $res = <$socket>;$res =~ m(^HTTP/1\.1 200 OK\r\n) or die $res;$res =~ s/.*?\r\n\r\n//s;open my $out, qq(>), qq(cpanm) or die $!;print $out $res"
Enter fullscreen mode Exit fullscreen mode

The answer is using IO::Socket::INET.

If Perl is 5.14+, Perl has a HTTP client called HTTP::Tiny.

Examples on Github Action

The example to donwload cpanm on Github Action.

https://github.com/yuki-kimoto/SPVM/blob/build/.github/workflows/linux-ubuntu-latest-32bit.yml

Note for Beginners

cpanm is a tool to download Perl modules from CPAN. CAPN have many module distributions that are uploaded by Perl users.

Before Fixed(Old content)

On Linux/UNIX, Mac, Windows/PowerShell

perl -Mstrict -Mwarnings -MIO::Socket::INET -e 'my $socket = IO::Socket::INET->new(PeerAddr => qq(cpanmin.us), PeerPort => 80, Proto=> qq(tcp));print $socket qq(GET / HTTP/1.0\r\nHost:cpanmin.us\r\n\r\n);binmode STDOUT;print <$socket>;' | perl -p -0777 -e 'BEGIN { binmode STDOUT;binmode STDIN  } s/.*?\r\n\r\n//s' > cpanm

Enter fullscreen mode Exit fullscreen mode

On Windows/Command Prompt:

perl -Mstrict -Mwarnings -MIO::Socket::INET -e "my $socket = IO::Socket::INET->new(PeerAddr => qq(cpanmin.us), PeerPort => 80, Proto=> qq(tcp));print $socket qq(GET / HTTP/1.0\r\nHost:cpanmin.us\r\n\r\n);binmode STDOUT;print <$socket>;" | perl -p -0777 -e "BEGIN { binmode STDOUT;binmode STDIN  } s/.*?\r\n\r\n//s" > cpanm

Enter fullscreen mode Exit fullscreen mode
cpan Article's
30 articles in total
Favicon
A link site of your very own
Favicon
App::cpx
Favicon
Combining calendars
Favicon
Installing CPAN modules from git
Favicon
Deploying Dancer Apps
Favicon
Feature release 1.36 of the Date::Holidays Perl distribution
Favicon
Building a tool to integrate Readwise.io highlights into my Zettelkasten via Perl
Favicon
Dist::Zilla::Plugin::GitHub::CreateRelease
Favicon
GitHub Organisations
Favicon
Mission (Almost) Accomplished
Favicon
Writing a CPAN module that talks to ChatGPT
Favicon
How to download cpanm in the portable way that supports Perl 5.8.1
Favicon
SPVM::IO 0.14 is released on Perl/CPAN
Favicon
Feature release 1.32 of Date::Holidays Perl distribution
Favicon
CPAN Module Tutorials
Favicon
cpanm - Installation of Perl Modules on User Directories 2022
Favicon
Wrapping a JSON API to access your personal data
Favicon
Highlighting members of the Perl family
Favicon
Create foo.a using Pure Perl and Archive::Ar
Favicon
Multiple ways to inheritance in Perl
Favicon
Taming the Moose: Classing up Perl attributes
Favicon
Some thoughts on Perl template processing
Favicon
Making Single-binary Release with pp
Favicon
The reports of Perl’s death have been greatly exaggerated
Favicon
Read The Fantastic Manual: How to get the most out of Perl documentation
Favicon
Failing to get product information from Amazon with Perl
Favicon
CPAN Release of TooMuchCode 0.18
Favicon
Fast Perl module installation with cpm
Favicon
CPAN installation as a test, with GitHub workflow
Favicon
CPAN Release of TooMuchCode 0.17

Featured ones: