unlink如果文件已打开,则不会删除该文件; 它只是删除名称和名称的链接.可以unlink撤消?
open(my $fh, ">", undef) || die;
print $fh "foo";
# This does not work
link($fh,"/tmp/bar") || die;
Run Code Online (Sandbox Code Playgroud)
可以将未链接文件的打开文件句柄链接到文件吗?
这些答案说:“不,不是一般情况下,而且绝对不是在所有 Unices 上”:
https://serverfault.com/questions/168909/relinking-a-deleted-file
从打开的文件句柄复制内容可能有效。