Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个将文件移动到文件夹中的 Perl 脚本。每次运行时,它都会检查文件夹中的文件名。但是如果我有一个更大的文件,当它检查文件名时它可能还没有准备好移动,它真的会搞砸一些东西。我想在循环结束时停下来检查移动是否完成,然后再继续。
三种常用方法。
sleep 1 while -e $original_filename;
有许多选项,甚至是无限的 while 选项,但是您需要格式化代码以确保在文件永远不存在时不会将脚本置于永久循环中。