tags:

views:

81

answers:

4

Hi all

I want to use the perl to check the hard disk space on Windows, is there any way to do it?

Best Regards,

+1  A: 

Win32 Drive Info should do the trick.
I guess your are looking for

$TotalNumberOfFreeBytes

weismat
+4  A: 

see Win32::DriveInfo

($SectorsPerCluster, $BytesPerSector, $NumberOfFreeClusters, 
$TotalNumberOfClusters, $FreeBytesAvailableToCaller, $TotalNumberOfBytes, $TotalNumberOfFreeBytes) =  Win32::DriveInfo::DriveSpace( drive );

   $SectorsPerCluster          - number of sectors per cluster.
   $BytesPerSector             - number of bytes per sector.
   $NumberOfFreeClusters       - total number of free clusters on the disk.
   $TotalNumberOfClusters      - total number of clusters on the disk.
   $FreeBytesAvailableToCaller - total number of free bytes on the disk that
                                 are available to the user associated with the
                                 calling thread, b.
   $TotalNumberOfBytes         - total number of bytes on the disk, b.
   $TotalNumberOfFreeBytes     - total number of free bytes on the disk, b.
Nikhil Jain
+3  A: 

Most of the time, a portable solutions such as Filesys::DfPortable is the better choice. Recognise the opportunity to be virtuously lazy.

daxim
A: 

Another way to query the system state is to query the Windows Management Interface using DBD::WMI.

The following query should give you the basic info about disk space:

Select DeviceID,Size,FreeSpace from Win32_LogicalDisk
dolmen