[Thu Jul 30 09:39:37 2009] upload.pl: Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::UPLOAD_DIR redefined at /usr/share/perl/5.10/constant.pm line 115,line 133.Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::BUFFER_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133 (#1)[Thu Jul 30 09:39:37 2009] upload.pl: Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::BUFFER_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133.Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_file_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133 (#1)[Thu Jul 30 09:39:37 2009] upload.pl: Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_file_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133.Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_DIR_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133 (#1)[Thu Jul 30 09:39:37 2009] upload.pl: Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_DIR_SIZE redefined at /usr/share/perl/5.10/constant.pm line 115,line 133.Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_OPEN_TRIES redefined at /usr/share/perl/5.10/constant.pm line 115,line 133 (#1)[Thu Jul 30 09:39:37 2009] upload.pl: Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::MAX_OPEN_TRIES redefined at /usr/share/perl/5.10/constant.pm line 115,line 133.Subroutine dir_size redefined at /home/stanislav/cgi/perl/upload.pl line 79,line 133 (#2)[Thu Jul 30 09:39:37 2009] upload.pl: Subroutine dir_size redefined at /home/stanislav/cgi/perl/upload.pl line 79,line 133.Subroutine error redefined at /home/stanislav/cgi/perl/upload.pl line 90,line 133 (#2)[Thu Jul 30 09:39:37 2009] upload.pl: Subroutine error redefined at /home/stanislav/cgi/perl/upload.pl line 90,line 133.Argument "" isn't numeric in numeric ge (>=) at /home/stanislav/cgi/perl/upload.pl line 62 (#4)[Thu Jul 30 09:39:37 2009] -e: Argument "" isn't numeric in numeric ge (>=) at /home/stanislav/cgi/perl/upload.pl line 62.filehandle OUTPUT opened only for input at /home/stanislav/cgi/perl/upload.pl line 69 (#5)[Thu Jul 30 09:39:37 2009] -e: filehandle OUTPUT opened only for input at /home/stanislav/cgi/perl/upload.pl line 69.Constant subroutine ModPerl::ROOT::ModPerl::Registry::home_stanislav_cgi_perl_upload_2epl::UPLOAD_DIR redefined at /usr/share/perl/5.10/constant.pm line 115,line 133 (#1)
为什么这条线路存在并且有办法阻止它们?
发出此警告的代码(摘自“使用Perl进行CGI编程”一书
错误修复):
#!/usr/bin/perluse strict;use warnings;use CGI;use CGI::Carp;#use diagnostics qw/-verbose/;use Fcntl qw( :DEFAulT :flock );use constant UPLOAD_DIR => "/tmp/test_upload/";use constant BUFFER_SIZE => 16_384;use constant MAX_file_SIZE => 1_048_576; # limit each upload to 1 MBuse constant MAX_DIR_SIZE => 100 * 1_048_576; # limit total uploads to 100 MBuse constant MAX_OPEN_TRIES => 100;$CGI::disABLE_UPLOADS = 0;$CGI::POST_MAX = MAX_file_SIZE;my $q = new CGI;$q->cgi_error and error( $q,"Error transferring file: " . $q->cgi_error );my $file = $q->param( "file" ) || error( $q,"No file received." );my $filename = $q->param( "filename" ) || error( $q,"No filename entered." );my $fh = $q->upload( "file" ) || error( $q,"Something is wrong with file handle." );#my $fh = $q->upload( $file );my $buffer = "";if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH} > MAX_DIR_SIZE ) { error( $q,"Upload directory is full." );}# Allow letters,digits,periods,underscores,dashes# Convert anything else to an underscore$filename =~ s/[^\w.-]/_/g;if ( $filename =~ /^(\w[\w.-]*)/ ) { $filename = ;}else { error( $q,"InvalID file name; files must start with a letter or number." );}# Open output file,making sure the name is uniqueuntil ( sysopen OUTPUT,UPLOAD_DIR . $filename,O_CREAT | O_EXCL ) { $filename =~ s/(\d*)(\.\w+)$/(||0) + 1 . /e; >= MAX_OPEN_TRIES and error( $q,"Unable to save your file." );}# This is necessary for non-Unix systems; does nothing on Unixbinmode $fh;binmode OUTPUT;# Write contents to output filewhile ( read( $fh,$buffer,BUFFER_SIZE ) ) { print OUTPUT $buffer;}close OUTPUT;if ( -T $fh ) { print $q->header("text/plain"); seek $fh,0; map { print } ;}sub dir_size { my $dir = shift; my $dir_size = 0; # Loop through files and sum the sizes; doesn't descend down subdirs opendir DIR,$dir or dIE "Unable to open $dir: $!"; while ( $_ = readdir DIR ) { $dir_size += -s "$dir/$_"; } return $dir_size;}sub error { my( $q,$reason ) = @_; print $q->header( "text/HTML" ),$q->start_HTML( "Error" ),$q->h1( "Error" ),$q->p( "Your upload was not procesed because the following error ","occured: " ),$q->p( $q->i( $reason ) ),$q->end_HTML; exit;}
此代码具有类似的输出:
$perl -e’sub FOO(){1} BEGIN {* FOO = sub(){2};打印FOO;’
Constant subroutine main::FOO redefined at -e line 1.
我确实没有发出任何警告qw /重新定义/但它没有帮助.
解决方法 AFAIK,您只有在修改脚本时才会收到这些警告,然后mod_perl会为有资格进行内联的子程序重新编译脚本.重新编译子例程时,如果返回的值发生更改,则该新值不会反映在以前内联的位置.如果更改BUFFER_SIZE的值,则应重新启动apache.
我还认为mod_perl / Apache::Registry accidental closures与您的脚本相关.
总结以上是内存溢出为你收集整理的为什么我在mod_perl下使用“use constant”获得“重新定义”警告?全部内容,希望文章能够帮你解决为什么我在mod_perl下使用“use constant”获得“重新定义”警告?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)