我如何在Perl中打印哈希的内容? [英] How can I print the contents of a hash in Perl?
本文介绍了我如何在Perl中打印哈希的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直打印我的散列为#桶/#分配。
如何打印我的散列的内容?
I keep printing my hash as # of buckets / # allocated. How do I print the contents of my hash?
如果不使用,而
循环将是最优选的(例如,单行将是最好的)。
Without using a while
loop would be most preferable (for example, a one-liner would be best).
推荐答案
Data :: Dumper 是你的朋友。
use Data::Dumper;
my %hash = ('abc' => 123, 'def' => [4,5,6]);
print Dumper(\%hash);
会输出
$VAR1 = {
'def' => [
4,
5,
6
],
'abc' => 123
};
这篇关于我如何在Perl中打印哈希的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文