我正在尝试在Windows 7上的Strawberry Perl中安装Perl模块.
我正在运行以下命令,我收到了一些我不明白的消息.看起来我得到500个错误,好像页面无法访问.但是,当我在浏览器中指向镜像时,访问FTP目录没有问题.我在Linux上有很少的Perl经验,在Windows上没有经验.我尝试手动为urllist添加一个镜像,我觉得这没有帮助.
C:\Program Files> cpan Win32::IE::Mechanize
CPAN: LWP::UserAgent loaded ok (v5.835)
CPAN: Time::HiRes loaded ok (v1.9721)
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
LWP failed with code[500] message[Can't connect to cpan.strawberryperl.com:80 (Bad hostname 'cpan.strawberryperl.com')]
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it.
Fetching with LWP:
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz
LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname 'mirror.teklinks.com']
Fetching with Net::FTP:
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz
Could not connect to host 'mirror.teklinks.com' with Net::FTP
Fetching with Net::FTP
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz.gz
Could not connect to host 'mirror.teklinks.com' with Net::FTP
Warning: no …Run Code Online (Sandbox Code Playgroud) 我有一个Perl脚本,它有两个CPAN中存在的依赖项.我想要做的是让脚本本身提示用户安装必要的依赖项,以便脚本能够正常运行.如果用户需要输入某种身份验证来安装那些没关系的依赖项:我要避免的是以下工作流程:
运行脚本 - >观察它失败 - >漫无目的地搜索CPAN - > Lynch脚本编写者
相反,我希望有类似的东西:
运行脚本 - >自动下载脚本依赖项(根据需要进行身份验证) - >脚本成功 - >购买脚本编写器啤酒
可以这样做吗?
我在企业环境中有一个Linux机器,其中Web访问通过需要身份验证的代理进行门控.
在第一次运行cpan期间,它会自动配置它通常执行的所有操作:
自动配置除"urllist"之外的所有内容.请立即拨打'o conf init urllist'配置您的CPAN服务器!
commit:写道'/usr/lib/perl5/5.10.0/CPAN/Config.pm'
知道我有一个代理来导航,并在网上阅读有关代理和cpan的文档和几个页面我:
cpan [1]> o conf init/proxy /
如果您通过代理访问网络,则可以在CPAN配置中或通过环境变量指定它们.$ CPAN :: Config中的变量优先.
你的ftp_proxy?[]
你的http_proxy?[] 10.12.8.9:3128
你的no_proxy?[]
如果您的代理是身份验证代理,则可以永久存储您的用户名.如果您不想这样,只需按RETURN即可.然后,您将在以后的每个会话中被要求提供用户名.
您的代理用户ID?[] my_net_id
您的身份验证代理的密码也可以永久存储在磁盘上.如果这违反了您的安全政策,只需按RETURN即可.然后,您将在以后的每个会话中被要求输入密码.
CPAN:Term :: ReadKey加载好(v2.30)您的代理密码?请记得调用'o conf commit'来使配置永久化!
cpan [2]> o conf commit commit:写道'/usr/lib/perl5/5.10.0/CPAN/Config.pm'
现在一切都应该好,对吧?所以我希望,
cpan [3]> i/Some :: Module/CPAN:Storable loaded ok(v2.18)
我想连接到以下网站之一以获取'authors/01mailrc.txt.gz':
http://www.perl.org/CPAN/ ftp://ftp.perl.org/pub/CPAN/
尝试连接到Internet可以吗?[是] LWP无法使用
尝试使用"/ usr/bin/curl -L -f -s -S --netrc-optional"来获取 http://www.perl.org/CPAN/authors/01mailrc.txt.gz卷曲:(22)请求的URL返回错误:407
系统调用"/ usr/bin/curl -L -f -s -S --netrc-optional" http://www.perl.org/CPAN/authors/01mailrc.txt.gz "> /root/.cpan/ sources/authors/01mailrc.txt.tmp29726"返回状态22(wstat 5632)警告:预期文件[/root/.cpan/sources/authors/01mailrc.txt.gz.tmp29726]不存在
尝试使用"/ usr/bin/wget -O /root/.cpan/sources/authors/01mailrc.txt.tmp29726"获取 http://www.perl.org/CPAN/authors/01mailrc.txt.gz - 2012-07-17 15:57:38-- http://www.perl.org/CPAN/authors/01mailrc.txt.gz …
我将花30分钟向一位经验丰富的程序员教授Perl.学习Perl的最好方法是编写代码.除了CPAN之外,你会向程序员展示什么,以便他们理解Perl的表现力,CPAN提供的功能量,同时保持一切干净整洁,让他们对语言感到满意?我会把这些棘手的东西保存到另一天.
use warnings;
use strict;
# use A_CPAN_LIB;
sub example_func1 {
# use the CPAN lib or demonstrate some basic feature of Perl
}
example_func1();
# ...
__END__
信不信由你,男人页.好吧,我们只是使用perldoc代替Windows友好.
perldoc页面(或Unix/Mac上的手册页)非常适合Perl.你可以输入man perl或perldoc perl
perldoc perl ; #显示概述和几十个教程; 男人perl是一样的.
perldoc perlintro ; #初学者的Perl介绍; 男人perlintro
perldoc perlrequick ; #Perl正则表达式的一个例子
perldoc perlfunc ; #显示内置Perl函数
perldoc perlre ; #更多Perl正则表达式.
Perl库站点CPAN上有数千个库.
perl -MCPAN -e'安装DateTime'
perldoc也适用于已安装的模块:perldoc模块
perldoc DateTime
perldoc DBI ; #Database API.如果这不起作用,那么安装它:
perl -MCPAN -e'install DBI'
perl -MCPAN -e'安装Moose' ; #Perl做OOP …
这是安装的标准输出:
CPAN Terminal> i Net::SSLeay
Installing Net::SSLeay (1.58)
Running [/usr/bin/perl /usr/bin/cpanp-run-perl /home/greymonkey/.cpanplus/5.14.2/build/Net-SSLeay-1.58/Makefile.PL INSTALLDIRS=site]...
*** Found OpenSSL-1.0.1e installed in /usr
*** Be sure to use the same compiler and options to compile your OpenSSL, perl,
and Net::SSLeay. Mixing and matching compilers is not supported.
Do you want to run external tests?
These tests *will* *fail* if you do not have network connectivity. [n]
Checking if your kit is complete...
Looks good
Writing Makefile for Net::SSLeay
Writing MYMETA.yml
[ERROR] MAKE failed: No …Run Code Online (Sandbox Code Playgroud) 出于业余爱好的目的,我在托管服务器上有一个共享空间,它提供了许多PHP和Perl CGI.我已经阅读了几个CGI脚本现在已经过时的地方了,我认为主要是针对性能问题(比如PHP或vanilla Perl CGI更快吗?).
但是,自从我刚开始学习Perl以来,我不想浪费时间在PHP中实现更容易(或仅可能)在Perl中的解决方案.
还有样板问题,我知道CPAN(这是存在的,还不是内容),但不熟悉PHP库(虽然我毫不怀疑它们存在).我不准备从头开始编写登录程序或基本用户管理10 ^ 10次.
在这一点上,我也没有浪费大量时间研究业余爱好项目,所以我想,让我们请专家们了解一下.
我想为我自己的"默认使用"制作一个模块,例如:
use My::perldefs;
Run Code Online (Sandbox Code Playgroud)
具有以下内容(主要基于tchrist的帖子.)
use 5.014;
use strict;
use features qw(switch say state);
no warnings;
use warnings qw(FATAL closed threads internal debugging pack substr malloc
unopened portable prototype inplace io pipe unpack regexp
deprecated exiting glob digit printf utf8 layer
reserved parenthesis taint closure semicolon);
no warnings qw(exec newline);
use utf8;
use open qw(:std :utf8);
use charnames qw(:full);
use feature qw(unicode_strings);
use Encode qw(encode decode);
use Unicode::Normalize qw(NFD NFC);
use Carp qw(carp croak confess cluck);
use autodie; …Run Code Online (Sandbox Code Playgroud) 在cpan shell中,只有/ regexp /或所有模块都可以升级,如果我想升级只由CPAN安装的模块,该怎么办?
我安装了这样的CPAN模块:
cpan Acme
Run Code Online (Sandbox Code Playgroud)
根据输出,安装成功:
Running install for module 'Acme'
...
All tests successful.
Files=2, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.04 cusr 0.00 csys = 0.06 CPU)
Result: PASS
INGY/Acme-1.11111111111.tar.gz
/usr/bin/make test -- OK
Running make install
Manifying 1 pod document
Installing /home/foo/perl5/lib/perl5/Acme.pod
Installing /home/foo/perl5/lib/perl5/Acme.pm
Installing /home/foo/perl5/man/man3/Acme.3pm
Appending installation info to /home/foo/perl5/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
INGY/Acme-1.11111111111.tar.gz
/usr/bin/make install -- OK
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用该模块时,我收到一个错误:
$ perl -MAcme -e1
Can't locate Acme.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .). …Run Code Online (Sandbox Code Playgroud) cpan ×10
perl ×10
automation ×1
cgi ×1
dbi ×1
dependencies ×1
installation ×1
module ×1
php ×1
proxy ×1
upgrade ×1
utf-8 ×1