defined 函数使用

#如果给定的值不是undef, defined()函数会返回 true 
#如果给定值是undef 则返回false.


my $test01 = "" ;

#it return ture it will print string.
if (defined $test01){
    print "var is defined\n";
}

#it return false it will print string.
if (! defined $test02){
    print "var is undef\n";
}
posted @ 2018-01-07 16:34  小怪兽&奥特曼  阅读(264)  评论(0编辑  收藏  举报