如何访问存储在哈希中的数据 [英] How to access data stored in Hash

查看:116
本文介绍了如何访问存储在哈希中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

$coder = JSON::XS->new->utf8->pretty->allow_nonref;
%perl = $coder->decode ($json);

当我写print %perl变量时,它说HASH(0x9e04db0).如何访问此HASH中的数据?

When I write print %perl variable it says HASH(0x9e04db0). How can I access data in this HASH?

推荐答案

decode的返回值不是哈希值,您不应该将其分配给%hash -执行此操作时,您将销毁它的价值.这是一个哈希 reference ,应分配给标量.阅读 perlreftut .

The return value of decode isn't a hash and you shouldn't be assigning it to a %hash -- when you do, you destroy its value. It's a hash reference and should be assigned to a scalar. Read perlreftut.

这篇关于如何访问存储在哈希中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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