gpt4 book ai didi

perl - 带有 undef 项的引用词函数

转载 作者:行者123 更新时间:2023-12-02 06:20:21 25 4
gpt4 key购买 nike

在 perl 中使用引号时,列表中是否可以有 undef 值?

my @ number_array = qw( 1 2 3 4 5 6 7 8 9 10 )

我想知道是否可以向该列表添加一个 undef 值,以便它包含 11 个值而不是 10 个值?

最佳答案

perl 中没有null,但是可以使用undef。由于 qw 明确地只对空格分隔的字符串进行操作,因此您必须在 qw 之外指定它,但您可以轻松地在括号内编写多个列表:

my @number_array = (undef, qw( 1 2 3 4 5 6 7 8 9 10 ));
print scalar @number_array;

>11

关于perl - 带有 undef 项的引用词函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12079855/

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