判消做断字符串是否为空一般用以下可以了:
if(!$str) {
print "this is an empty/undefined string\n "
}
如果你还想区别空串 " " 和未赋有效值的串可以缺桥磨用伏斗
if(!$str) {
if(defined $str) {
print "this is an empty string\n "
}
else {
print "this is an undefined string\n "
}
}
dosomething() unless(defined $var);