Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在输入空白查询时退出脚本。根据我的阅读,这段代码应该可以正常工作,但似乎不想这样做,因为“”不是数字。解决方法是什么?
if(($#ARGV < 0) || ($ARGV[0] == "")){ print "$0: Enter a query.\n"; exit 1; }
澄清,
perl run.pl "query"
应该工作,而
perl run.pl ""
应该提示输入一个字符串。
尝试
if(($#ARGV < 0) || ($ARGV[0] eq "")){ print "$0: Enter a query.\n"; exit 1; }
eq用于字符串比较。
eq