这是主文件upload.cgi
#!/usr/bin/perl
use strict;
use lib '.';
use XFSConfig;
use XUpload ;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Fcntl ':flock';
use LWP::UserAgent;
use HTTP::Cookies;
use HTML::Form;
use Encode;
sub xmessage
{
my ($msg) = @_;
&lmsg($msg);
$msg=~s/'/\\'/g;
$msg=~s/<br>/\\n/g;
print"Content-type: text/html\n\n";
print"<HTML><HEAD><Script>alert('$msg');</Script></HEAD><BODY><b>$msg</b></BODY></HTML>";
exit;
}
sub lmsg
{
my $msg = shift;
open(F,">$c->{htdocs_tmp_dir}/$sid.html");
print F qq[new Object({"state":"error", "msg":"$msg"})];
close F;
&logit($msg);
}
并且此函数调用函数
&XUpload::ProcessFile()
和XUpload :: ProcessFile()函数调用函数&amp; xmessage(“Fatal”);在upload.cgi中定义
现在我收到此错误
Undefined subroutine &XUpload::xmessage called at Modules/XUpload.pm line 17.
似乎包XUpload无法找到upload.cgi中定义的函数xmessage
答案 0 :(得分:0)
cgi脚本中的xmessage
sub在main
包中定义,而XUpload
模块(显然)在XUpload
命名空间中运行。
解决此问题最终将涉及了解Perl的命名空间和Exporter
模块。但快速而又脏的修复方法是在XUpload
包中为您的sub创建别名。将此行添加到主脚本:
*XUpload::xmessage = *message;