perl版本过高,Can't use 'defined(@array)' (Maybe you should just omit the defined()?)如何解决

编译打包和其他
回复
ilovewapple
帖子: 4
注册时间: 2022-06-08 16:04
系统: ubuntu18.04.6 LTS

perl版本过高,Can't use 'defined(@array)' (Maybe you should just omit the defined()?)如何解决

#1

帖子 ilovewapple » 2022-06-16 9:06

在利用perl时,出现这个错误:
Can't use 'defined(@array)' (Maybe you should just omit the defined()?)

目前perl版本为v5.26.1,百度了下,说是perl版本太高出现的bug。有些人说去掉defined有用,有些说去掉了还是会有问题。问下大家,是否有其他的解决办法?
头像
astolia
论坛版主
帖子: 6477
注册时间: 2008-09-18 13:11

Re: perl版本过高,Can't use 'defined(@array)' (Maybe you should just omit the defined()?)如何解决

#2

帖子 astolia » 2022-06-16 12:58

要看具体的代码是什么。
defined(@array)曾经可以用来判断array是否为空数组。所以以前的代码中会看到 if(defined(@xxx))这样的写法
但perl 5.16之后,不再支持将defined函数用在数组上,上面的那种写法需要改成if(@xxx)。
回复