为什么Perl的File :: Copy似乎无声地失败?

前端之家收集整理的这篇文章主要介绍了为什么Perl的File :: Copy似乎无声地失败?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个适用于 Windows XP的Perl脚本.
它使用File :: Copy的移动功能将目录树移动到同一驱动器上的另一个位置.该脚本在Windows 2008上失败(静默).没有任何移动,没有删除任何内容.

我正在使用ActiveState Perl 5.10.0 Build 1005和它附带的File :: Copy.

有人知道Windows 2008上的ActiveState Perl可能会导致这个问题吗?

示例脚本:

use File::Copy;
print "Move AAA to ZZZ\n";

move("AAA","ZZZ");

print "Done.\n";

解决方法

documentation

RETURN

All functions return 1 on success,0 on failure. $! will be set
if an error was encountered.

这个例子无声地失败,因为什么都没有检查$!失败了.试试这个:

move($from,$to) || die "Failed to move files: $!";

猜你在找的Perl相关文章