2017年8月7日 星期一

Perl for Windows

Perl for windows

依據 https://www.perl.org/ 這裡的介紹,我們可以知道 Perl 可以在不同的平台上使用,
如 AIX/Solaris/Linux/FreeBSD/Windows/MAC OS.....

但在 Windows 平台上並沒有內建 Perl 的,所以得另外安裝,目前較多人使用有:

Strawberry Perl ( http://strawberryperl.com/ )

ActivePerl ( https://www.activestate.com/activeperl )

以 ActivePerl 為例可透過 ppm 去安裝 perl module ,
ppm 是一個 Windows UI 介面的安裝
如下圖中的 ActivePerl  為 5.20.2 (目前官網上已有更新至其它較新版本)

Microsoft Windows [版本 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\user>perl -v

This is perl 5, version 20, subversion 2 (v5.20.2) built for MSWin32-x86-multi-thread-64int
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2015, Larry Wall

Binary build 2001 [298913] provided by ActiveState http://www.ActiveState.com
Built Mar 19 2015 15:26:52

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


C:\Users\user>


另外 如使用  Strawberry Perl  則可使用 cpan or cpanm 去安裝,
下面 Demo 為  Strawberry Perl ( 5.26.0 )

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>perl -v

This is perl 5, version 26, subversion 0 (v5.26.0) built for MSWin32-x86-multi-thread-64int

Copyright 1987-2017, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


C:\Windows\system32>cpanm
Usage: cpanm [options] Module [...]

Try `cpanm --help` or `man cpanm` for more options.

C:\Windows\system32>cpanm LINE::Bot::API
--> Working on LINE::Bot::API
Fetching http://www.cpan.org/authors/id/Y/YA/YAPPO/LINE-Bot-API-1.04.tar.gz ...
OK
Configuring LINE-Bot-API-1.04 ... OK
==> Found dependencies: Furl
--> Working on Furl
Fetching http://www.cpan.org/authors/id/T/TO/TOKUHIROM/Furl-3.11.tar.gz ... OK
Configuring Furl-3.11 ... OK
==> Found dependencies: HTTP::Parser::XS, Test::TCP
--> Working on HTTP::Parser::XS
Fetching http://www.cpan.org/authors/id/K/KA/KAZUHO/HTTP-Parser-XS-0.17.tar.gz .
.. OK
Configuring HTTP-Parser-XS-0.17 ... OK
Building and testing HTTP-Parser-XS-0.17 ... OK
Successfully installed HTTP-Parser-XS-0.17
--> Working on Test::TCP
Fetching http://www.cpan.org/authors/id/T/TO/TOKUHIROM/Test-TCP-2.19.tar.gz ...
OK
Configuring Test-TCP-2.19 ... OK
==> Found dependencies: Test::SharedFork
--> Working on Test::SharedFork
Fetching http://www.cpan.org/authors/id/E/EX/EXODIST/Test-SharedFork-0.35.tar.gz
 ... OK
Configuring Test-SharedFork-0.35 ... OK
Building and testing Test-SharedFork-0.35 ... OK
Successfully installed Test-SharedFork-0.35
Building and testing Test-TCP-2.19 ... O
......
.........

這要看個人喜愛,這2個都不錯...


當然  ActivePerl  也是可以在 CLI 下 ppm install 去裝 Perl module 如下 Demo...

C:\Perl\bin>ppm install LINE-Bot-API
Downloading LINE-Bot-API-1.04...done
Downloading Furl-3.08...done
Downloading JSON-XS-3.03...done
Downloading HTTP-Parser-XS-0.17...done
Downloading Class-Accessor-Lite-0.08...done
Downloading common-sense-3.74...done
Downloading Types-Serialiser-1.0...done
Unpacking LINE-Bot-API-1.04...done
Unpacking Furl-3.08...done
Unpacking JSON-XS-3.03...done
Unpacking HTTP-Parser-XS-0.17...done
Unpacking Class-Accessor-Lite-0.08...done
Unpacking common-sense-3.74...done
Unpacking Types-Serialiser-1.0...done
Generating HTML for LINE-Bot-API-1.04...done
Generating HTML for Furl-3.08...done
Generating HTML for JSON-XS-3.03...done
Generating HTML for HTTP-Parser-XS-0.17...done
Generating HTML for Class-Accessor-Lite-0.08...done
Generating HTML for common-sense-3.74...done
Generating HTML for Types-Serialiser-1.0...done
Updating files in site area...done
  54 files installed

C:\Perl\bin>