您的位置:首页 > 其它

perl 数组元素为空和数组元素为undef 是两码事

2015-12-04 12:55 225 查看
[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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: