我必须怎么做才能防止 Perl 抱怨“不推荐使用哈希作为参考"? [英] What must I do to prevent Perl from complaining that "using a hash as a reference is deprecated"?

查看:23
本文介绍了我必须怎么做才能防止 Perl 抱怨“不推荐使用哈希作为参考"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码来自旧的 Perl 脚本.

The code below is from an old Perl script.

print "%{@{$noss}[$i]}->{$sector} \n\n";

我应该如何重写上面的代码,以便 Perl 不会抱怨不推荐使用哈希作为引用"?我尝试了各种方法,但仍然无法完全掌握 Perl 编译器要我做什么.

How should I rewrite the code above so that Perl does not complain that "using a hash as a reference is deprecated"? I have tried all sorts of way but I still couldn't quite get the hang of what the Perl compiler want me to do.

推荐答案

print "%{@{$noss}[$i]}->{$sector} \n\n";

应该只是

print "$noss->[$i]{$sector} \n\n";

甚至

print "$$noss[$i]{$sector} \n\n";

没有那些杂烩.

这篇关于我必须怎么做才能防止 Perl 抱怨“不推荐使用哈希作为参考"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆