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

前端 未结 5 1432
庸人自扰
庸人自扰 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:18

    system returns the exit status of the command it calls. In shell, zero exit status means success. You have to invert the logic:

    0 == system qw(mkdir -p Purged) or die "Failed to create the dir\n";
    

提交回复
热议问题