[root@dr-mysql01 ~]# cat x.pl
@arr=($tmp1[-1], $tmp2[-1],2);
if (@arr){print "111111\n"};
print "\$arr[0] is $arr[0]\n";
print "\$arr[1] is $arr[1]\n";
[root@dr-mysql01 ~]# perl x.pl
111111
$arr[0] is
$arr[1] is
数组元素为空,和没有数组元素是两码事
[root@dr-mysql01 ~]# cat y.pl
@arr;
if (@arr){print "111111\n"};
print "\$arr[0] is $arr[0]\n";
print "\$arr[1] is $arr[1]\n";
[root@dr-mysql01 ~]# perl y.pl
$arr[0] is
$arr[1] is
perl 数组元素为空和数组元素为undef 是两码事
最新推荐文章于 2023-08-07 13:05:06 发布