gpt4 book ai didi

perl - 如何测试 "something"是 Perl 中的哈希?

转载 作者:行者123 更新时间:2023-12-03 10:33:15 25 4
gpt4 key购买 nike

我从另一个函数接收哈希哈希,哈希哈希的某些元素可以是另一个哈希。如何测试以查看某些内容是否为哈希?

最佳答案

使用 ref 功能:

ref($hash_ref) eq 'HASH' ## $hash_ref is reference to hash
ref($array_ref) eq 'ARRAY' ## $array_ref is reference to array

ref( $hash{$key} ) eq 'HASH' ## there is reference to hash in $hash{$key}

关于perl - 如何测试 "something"是 Perl 中的哈希?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3789284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com