为什么我得到“不能使用字符串作为 HASH 引用"?尝试访问散列元素时出错? [英] Why do I get "Can't use string as a HASH ref" error when I try to access a hash element?

查看:50
本文介绍了为什么我得到“不能使用字符串作为 HASH 引用"?尝试访问散列元素时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何解决这个错误?

How do I fix this error?

foreach (values %{$args{car_models}}) {
   push(@not_sorted_models, UnixDate($_->{'year'},"%o"));
}

错误:不能使用字符串 ("1249998666") 作为 HASH 引用,而在/.../BMW.pm 第 222 行使用严格引用".

Error: Can't use string ("1249998666") as a HASH ref while "strict refs" in use at /.../BMW.pm line 222.

推荐答案

Data::Dumper 模块在这种情况下非常有用——帮助你找出为什么复杂的数据结构不满足您的期望.例如:

The Data::Dumper module is extremely useful in such situations -- to help you figure out why a complex data structure is not meeting your expectations. For example:

use Data::Dumper;
print Dumper(\%args);

这篇关于为什么我得到“不能使用字符串作为 HASH 引用"?尝试访问散列元素时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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