2012-02-16 89 views
4

我需要获得可用磁盘空间,使用Perl的Windows机器的总磁盘空间。如何在Windows机器上使用perl查找磁盘空间?

举一个例子,

use strict; 
my $curr_drive="c:\"; 

从上面的代码,我想在C:\驱动器的可用空间和总空间。 我已经试过与Filesys :: DiskSpace模块。但我不知道如何进行Windows模块。 请分享您的解决方案。

感谢

+3

的[获取使用Perl硬盘信息]可能重复(http://stackoverflow.com/questions/ 3519575/get-the-hard-disk-information-using-perl) – geoffspear 2012-02-16 15:26:59

回答

4

模块Filesys::DiskSpace是不支持在Windows上。你必须使用Win32::DriveInfo

尝试以下操作:

use strict; 
use warnings; 

use Win32::DriveInfo; 

my (undef, undef, undef, undef, undef, $total, $free) = 
    Win32::DriveInfo::DriveSpace('c'); 
+0

正如[使用Perl获取硬盘信息]中所述(http://stackoverflow.com/questions/3519575/get-the-hard-disk- information-using-perl),'Filesys :: DfPortable;'模块应该是首选的便携式解决方案(支持Windows)。 – Ouki 2012-02-16 16:13:49