[Ubuntu]无法安装Cpan Install :: Thread

时间:2012-12-14 03:42:40

标签: multithreading perl cpan

我现在已经面临一些问题,谷歌还没有给我太多帮助。我想使用需要线程的perl程序但它给我带来了困难。我目前正在使用Perl 5.10.1,它不支持多线程,但通常我下面粘贴的命令应该没有任何问题。我很乐意为这位好帮手付出回报。

所以我试过这个:

sudo su -
cpan
install shared::thread

(高度损坏)输出:

root@noc:~# sudo su - root@noc:~# cpan Terminal does not support
AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> install shared::thread CPAN: Storable loaded ok (v2.20) Going
to read '/root/.cpan/Metadata' Database was generated on Wed, 12 Dec
2012 01:07:04 GMT CPAN: Time::HiRes loaded ok (v1.9719) Warning: no
success downloading
'/root/.cpan/sources/authors/01mailrc.txt.gz.tmp22514'. Giving up on
it. at /usr/lib/perl5/5.10.1/CPAN/Index.pm line 225 LWP not available

Trying with "/usr/bin/curl -L -f -s -S --netrc-optional" to get
"http://www.perl.org/CPAN/authors/01mailrc.txt.gz" CPAN:
Compress::Zlib loaded ok (v2.02) CPAN: YAML loaded ok (v0.84) Going to
read '/root/.cpan/sources/authors/01mailrc.txt.gz'
..................................................
..........................DONE Warning: no success downloading
'/root/.cpan/sources/modules/02packages.details.txt.gz.tmp22514'.
Giving up on it. at /usr/lib/perl5/5.10.1/CPAN/Index.pm line 225

Trying with "/usr/bin/curl -L -f -s -S --netrc-optional" to get
"http://www.perl.org/CPAN/modules/02packages.details.txt.gz" Going to
read '/root/.cpan/sources/modules/02packages.details.txt.gz' Database
was generated on Fri, 14 Dec 2012 01:07:03 GMT HTTP:ate not available
.............. New CPAN.pm version (v1.9800) available. [Currently
running version is v1.9402] You might want to try install CPAN reload
cpan to both upgrade CPAN.pm and run the new version without leaving
the current session.


.................................................. ............DONE
Warning: no success downloading
'/root/.cpan/sources/modules/03modlist.data.gz.tmp22514'. Giving up on
it. at /usr/lib/perl5/5.10.1/CPAN/Index.pm line 225

Trying with "/usr/bin/curl -L -f -s -S --netrc-optional" to get
"http://www.perl.org/CPAN/modules/03modlist.data.gz" Going to read
'/root/.cpan/sources/modules/03modlist.data.gz'
..................................................
..........................DONE Going to write /root/.cpan/Metadata
Warning: Cannot install shared::thread, don't know what it is. Try the
command

i /shared::thread/

to find objects with matching identifiers.

cpan[2]>

2 个答案:

答案 0 :(得分:3)

如果您需要Thread::Shared,则需要记住cpan区分大小写,请使用sudo cpan install Thread::Shared。您不需要在su

之后执行sudo

答案 1 :(得分:1)

  

我目前正在使用Perl 5.10.1,它不支持多线程

首先,让我们确定一下。如果你有一个支持线程的Perl,你会得到这个输出:

$ perl -V:usethreads
usethreads='define';

如果这就是你所得到的,那你只是拼错了“threads :: shared”,你甚至不需要安装,因为它已经与Perl一起提供了。

如果这不是你得到的,你的Perl不支持线程,你需要创建一个Perl版本(即构建一个使用-Dusethreads配置的Perl)。您不能只安装模块来添加线程支持,因为线程支持需要Perl内部的额外代码。


要自己构建Perl,我建议perlbrew,安装如下:

curl -kL http://install.perlbrew.pl | bash

(系统会指示您在登录脚本中添加一些内容,然后重新登录以确保一切设置正确。)

这样可以轻松安装新的Perl:

perlbrew install -v 5.16.2 --as=5.16.2t -Dusethreads