perl exist函数_Perl快速教程exist()函数

perl exist函数

Perl's exists() function is used to check whether an element in an array or hash exists. It can also be used to check for the existence of subroutines. exists will return true as long as the element has been initialized, and even if the element is undefined.

Perl的exist()函数用于检查数组哈希中的元素是否存在。 它也可以用来检查子程序的存在。 只要元素已初始化,即使元素未定义,则存在将返回true。

In the above example, we look at a hash of our contact Bob and his phone number. First, we check for the existence of the phone element, which is obviously returning true. Next, we check for an element that does not exist, address, and you'll see this one returns false.Let's look at the same routine, but with a blank address key:

在上面的示例中,我们查看了联系人Bob和他的电话号码的哈希值。 首先,我们检查phone元素是否存在,显然返回true 。 接下来,我们检查一个不存在的元素address ,您将看到这个返回false 。让我们看一下相同的例程,但是有一个空白的address键:

You'll see that this one returns true on the address, even though there is no actual value. Be careful relying on the logic of exists, and remember the distinction between exists and has value.

您会看到,即使没有实际值,该地址也将返回true。 要小心依靠存在的逻辑,并记住存在具有价值的区别。

翻译自: https://www.thoughtco.com/perl-exists-function-quick-tutorial-2641184

perl exist函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值