我有一个html文件,它将接受并发送登录名和密码。它被发送到文件login.cgi。为什么我的CGI脚本抱怨“在@INC中找不到CGI/Session.pm”?
**
- HTML文件
**
<form method="POST" action="login.pl">
<table >
<tr>
<td>Username </td>
<td bgcolor="lightgrey"><input type="text" name="usr" size="20"></td>
</tr>
<tr>
<td>Password </td>
<td bgcolor="lightgrey"><input type="password" name="pwd" size="20"></td>
</tr>
<tr>
<td><input type="submit" id ="Login" value="Login" name="login"/> </td>
</tr>
</table>
**
- 特等
**
#!/usr/bin/perl
# login.pl
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use CGI::Session ('-ip_match');
$q = new CGI;
$usr = $q->param('usr');
$pwd = $q->param('pwd');
if($usr ne '')
{
# process the form
if($usr eq "demo" and $pwd eq "demo")
{
$session = new CGI::Session();
print $session->header(-location=>'home.html');
}
else
{
print $q->header(-type=>"text/html",-location=>"LoginHtml.html");
}
}
elsif($q->param('action') eq 'logout')
{
$session = CGI::Session->load() or die CGI::Session->errstr;
$session->delete();
print $session->header(-location=>'LoginHtml.html');
}
else
{
print $q->header;
print <
<form method="post">
Username: <input type="text" name="usr">
Password: <input type="password" name="pwd">
<input type="submit">
</form>
HTML
}
启动Apache后,我打开网页,输入用户名作为演示和密码作为演示,并单击按钮。
我得到以下错误:
Software error:
Can't locate CGI/Session.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /var/www/cgi-bin/login.pl line 6. BEGIN failed--compilation aborted at /var/www/cgi-bin/login.pl line 6.
For help, please send mail to the webmaster ([email protected]), giving this error message and the time and date of the error.
请帮我解决这个错误。安装CGI-会话4.42后
**
- 编辑1
**
问题解决。
感谢大家,感谢您的帮助。
显然你没有安装CGI :: Session。从命令行尝试'cpan'并在开始的shell中运行'install CGI :: Session' ... – Boldewyn 2010-02-08 09:51:05
我试图安装cpan,但是每个连接都没有发生。另外,我在最后得到以下内容: 无法获取模块/ 03modlist.data.gz 要写入/root/.cpan/Metadata 警告:无法安装Bundle :: CPAN,不知道它是什么。 尝试命令 i/Bundle :: CPAN/ 查找具有匹配标识符的对象。 CPAN> I /捆绑:: CPAN/ 未找到的任何类型的用于参数/捆绑:: CPAN/ CPAN对象> /捆绑:: CPAN/ 无法找到对象的方法 “CPAN /” 通过包“/Bundle“(也许你忘了加载”/ Bundle“?)在/usr/lib/perl5/5.8.8/CPAN.pm 201行,第3行。 –
MalarN
2010-02-08 10:41:25