我在perl脚本中有一个perl子例程
sub constructSummaryString {
my ( $SummaryHash, $SeverityHash, $Component ) = @_;
foreach my $Key ( keys %$SummaryHash ) {
print %$SeverityHash->{$Key}; # <--- Warning at line:163
}
}
Run Code Online (Sandbox Code Playgroud)
子例程的输入是哈希引用.
当我尝试运行它时,我收到警告:
Using a hash as a reference is deprecated at xxxoo.pl line 163.
Run Code Online (Sandbox Code Playgroud)
警告意味着它的含义:您使用哈希作为参考,并且不推荐使用.看看声明:
%$SeverityHash->{$Key}
Run Code Online (Sandbox Code Playgroud)
这里,%$SeverityHash您的哈希引用被解除引用到哈希中.这个:->{$Key}你用它作为参考.
您需要做的是使用引用作为参考,而不是尝试和取消引用它.
$SeverityHash->{$Key}
Run Code Online (Sandbox Code Playgroud)