Perl: After a successful system call, “or die” command still ends script

前端 未结 5 1409
庸人自扰
庸人自扰 2020-12-17 16:46

I am using the following line to make a simple system call which works:

system (\"mkdir -p Purged\") or die \"Failed to mkdir.\" ;

Executin

5条回答
  •  無奈伤痛
    2020-12-17 17:05

    A one-line solution:

    system("if printf '' > tmp.txt; then exit 1; else exit 0; fi ;") or die("unable to clobber tmp.txt");
    

提交回复
热议问题