当我打印哈希值时,不断得到类似 2/8HASH(0x73609f8) 的信息

Keep getting something like 2/8HASH(0x73609f8) when I print a hash value

我通过迭代 keys %{$clause}

检查了 $clause 是一个散列引用,并且它有两个键 childrenjoiner

为了查看 children 键的值,我打印了它们。

sub _charts_to_conditions {
    my ($self) = @_;
    my $clause = $self->_charts;

    warn(%{$clause}.{'children'}); # print logs in server

    # some other logics
}

打印的值为

2/8HASH(0x73609f8)

我不确定 1/8 是什么意思,但因为它看起来像一个哈希引用,所以我也尝试打印它。

warn(%{%{$clause}.{'children'}});

结果

Can't use string ("2/8HASH(0x73609f8)") as a HASH ref while "strict refs" in use at <filename>

现在听起来 %{$clause}.{'children'} 是一个字符串。但是考虑到 2/8HASH(0x73609f8) 是多么无用的信息,我想,首先是出了大问题,我只是想念它。任何人都可以阐明什么对尝试有帮助吗?

给定 warn(%{$clause}.{'children'});,输出 2/8HASH(0x73609f8) 是两个值的串联 (.):标量上下文中的 %$clause,对于非空散列早于 5.26 的 perl 版本,returns number of entries/number of buckets(较新的版本只是 return 散列中的条目数),以及(格式错误的)散列引用 {'children'} .

如果您想打印该条目的值,您应该使用 warn $clause->{'children'};