无法使用perl中的unlink()删除xml文件

use*_*361 0 xml perl

我试图使用unlink()删除一个xml文件,但它没有删除它.

我使用它如下:

$file_loc = catfile( home_directory_path(), "builds","data.xml" );
unlink($file_loc);
Run Code Online (Sandbox Code Playgroud)

我可以在解析它时访问该文件.怎么了?是unlink()不是应该删除xml文件?

Joe*_*oel 5

请在代码中包含错误检查.你需要这个来弄清楚为什么unlink不起作用:

unlink $file_loc or warn "Could not unlink $file_loc: $!";
Run Code Online (Sandbox Code Playgroud)

这是从这里来的.