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