背景:
- 我正在努力将一台Linux服务器从Ubuntu 10.04迁移到12.04的新版本。
- 该服务器负责通过crontabs执行多个Perl模块。
- 这些Perl模块严重依赖于30-40个Perl扩展。
- 我已经安装了所有Perl扩展,crontabs能够成功处理,但由于这些Perl扩展的新版本导致的几个语法错误,无法正常处理。
- 我需要一些帮助来修改语法,使得Perl脚本能够按照预期进行处理。
错误:
defined(%hash) is deprecated at pm/Alerts/Alerts.pm line 943.
(Maybe you should just omit the defined()?)
defined(%hash) is deprecated at pm/Alerts/Alerts.pm line 944.
(Maybe you should just omit the defined()?)
代码:
###
# Iterate the arrays deleting identical counts from each.
# If we found a mismatch then die.
# If either array is not empty when we are done then die
$logger->info('Comparing ' . (scalar keys %cms_rows) . ' CMS symbols to ' . (scalar keys %stats_rows) . ' STATS symbols');
foreach my $symbol ( keys %cms_rows ) {
my %cms_row = delete $cms_rows{$symbol};
my %stats_row = delete $stats_rows{$symbol};
##LINE 943## die("Error: NULL CMS counts for symbol '$symbol'") unless defined %cms_row;
##LINE 944## die("Error: NULL Stats counts for symbol '$symbol'") unless defined %stats_row;
my $cms_json = encode_json(\%cms_row);
my $stats_json = encode_json(\%stats_row);
$logger->debug("Comparing counts for '$symbol': CMS($cms_json), Stats($stats_json)");
die("Error: Up Counts Don't match for symbol '$symbol': CMS($cms_json), Stats($stats_json)") unless (!defined $cms_row{1} && !defined $stats_row{1}) || $cms_row{1} == $stats_row{1};
die("Error: Down Counts Don't match for symbol '$symbol': CMS($cms_json), Stats($stats_json)") unless (!defined $cms_row{-1} && !defined $stats_row{-1}) || $cms_row{-1} == $stats_row{-1};
}
###
希望有人能够帮助解决这个问题,非常感激任何帮助。
unless %hash
。就像这个答案所显示的那样:https://dev59.com/uGox5IYBdhLWcg3wFAfW#9444942 - TLP