Perl - 错误 "Type of arg 1 to each must be hash (not hash element)"

标签 perl hash syntax

尝试运行此脚本时出现此错误 - 在此行

arg 1 to each 的类型必须是散列(不是散列元素)

    while (my ($action, $value) = each($cameras{$camera}{$mode})) {

如何修复此错误?

最佳答案

取消引用哈希:

 while (my ($action, $value) = each(%{ $cameras{$camera}{$mode} })) {

关于Perl - 错误 "Type of arg 1 to each must be hash (not hash element)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28017616/

相关文章:

ruby - 使用散列来区分正数、奇数、偶数和负数

c# - 用于匹配自定义语法的正则表达式

c - 访问结构和空指针

python - 更正 XML 编码

java - HashMap 的用户定义键类

arrays - 这个通过引用传递数组的示例在 Perl 中是如何工作的?

python - Python 中的 __hash__ 函数

c# - 自定义对象加法/减法

javascript - 如何最好地处理 Web 应用程序中的数据验证 : pure javascript code or ajax calls to familiar perl packages?

mysql - perl CGI radio_group : populate values from DB query