Chinaunix

标题: die小问题 [打印本页]

作者: bitterness    时间: 2008-12-10 12:34
标题: die小问题
#!/usr/bin/perl -w
$file="mer.log";
die "$file is exists!\n" if -e $file;
die "$file is execute!\n" if -x $file;
die "$file is wirteable!\n" if -w $file;


第一个执行完了,第二句就不执行了?
作者: churchmice    时间: 2008-12-10 12:36
你都已经死了
还怎么跑
作者: bitterness    时间: 2008-12-10 12:37
标题: 回复 #2 churchmice 的帖子
死了就直接退出整个程序了
我想一个个判断,用if 要打较多字
作者: churchmice    时间: 2008-12-10 12:41

  1. #!/usr/bin/perl -w
  2. $file="mer.log";
  3. print "$file is exists!\n" if -e $file;
  4. print "$file is execute!\n" if -x $file;
  5. print "$file is wirteable!\n" if -w $file;
复制代码

作者: churchmice    时间: 2008-12-10 12:41
用warn也可以
croak好像也可以
作者: bitterness    时间: 2008-12-10 12:46
OK
作者: 空气清新    时间: 2008-12-11 11:49
提示: 作者被禁止或删除 内容自动屏蔽
作者: 幸福家园    时间: 2008-12-11 11:50
...............




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2