无法找到 String/Random.pm

4

大家好,我有一个与Perl相关的错误。当我在浏览器中运行它时,会出现内部服务器错误;而当我在Ubuntu命令行中运行它时,也会出现错误。

Can't locate String/Random.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib
/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at CybOrg/Main.pm line 40.
BEGIN failed--compilation aborted at CybOrg/Main.pm line 40.
Compilation failed in require at login.pl line 26.
BEGIN failed--compilation aborted at login.pl line 26.

这是代码...
#!/usr/bin/perl
#
#    CybOrg - The Cybercafe Organizer
#    http://cyborg.sourceforge.net
#
#    Copyright (C) 2003 - The CybOrg Project
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License version 2 as 
#    published by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along 
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

use strict;
use warnings 'all';

use CybOrg::Main;
use CybOrg::Config;
use CybOrg::CGI;
use CybOrg::DB;

my $user_ok;
eval {
        $user_ok =  db_validate_user($params{'username'},$params{'password'});
};
if ($@) {
        $user_ok = '';
}

if ($user_ok) {
    my $session = send_cookie($params{'username'});
    eval {
        db_update_session($params{'username'}, $session);
    };
    if ($@) {
        redirect('cyborg.pl');
    } else {
        redirect('list.pl');
    }
} else {
    expire_cookie;
    redirect('cyborg.pl');
}

1;

I hoped U will help me... THANKS IN ADVANCE


1
String::Random未安装。请安装它。 - ikegami
如何安装它? 在Ubuntu中的命令是什么? 抱歉 Perl新手... 提前致谢 - user3367242
2
在Ubuntu上:如果您使用默认系统Perl,则执行sudo apt-get install libstring-random-perl。如果您有一些自定义设置,请执行cpanm String::Random或类似的操作。 - amon
谢谢大家, 我已经修复了错误。 谢谢。 - user3367242
请注意使用 String::Random。它是由 Steven Pritchard 在1999年编写的,但被 Shlomi Fish 声称并未做出任何更改。 - Borodin
2个回答

3
很可能,您需要安装String::Random
sudo cpan String::Random

通常情况下,cpan 会自动安装依赖项,但这需要在模块元数据中声明它们(显然您要安装的模块有着悠久的历史,因此可能会漏掉一些依赖项)。您可能会发现安装已经成功了,但是仍然有更多的依赖问题-只需逐个安装即可。

4
可选地,使用sudo apt-get install libstring-random-perl安装libstring-random-perl库。 - Hunter McMillen
1
建议阅读:最近Dave Cross写了一篇文章(http://perlhacks.com/2014/03/installing-modules/),建议在适当的情况下使用本地包管理器。我认为这是一个相当明智的理由。 - amon

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接