是不是说只有$#array =-1 时,才是数组为空?
On 12月15日, 下午3时16分, Michael Zeng <[email protected]> wrote: > 是的, undef 就是undef, 也是一种值 > > 2009/12/15 独孤九剑 <[email protected]> > > > > > if (@array) { > > print "数组不为空"; > > } > > else { > > print "数组为空"; > > } > > > 要注意的是,假使 @array = (undef); 那么,数组也不为空,因为有一个值为 undef 的数组元素,所以标量环境中 > > @array 的值为1,为真。 > > > -- > > > 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。 > > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > > 要取消订阅此网上论坛,请发送电子邮件至 > > [email protected]<perlchina%[email protected]> > > 。 > > 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。 > > -- > Yours Sincerely > Zeng Hong -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
